Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@jeffrey-xA7lUP • Sep 11, 2012
count me in i am in big trouble cos of data structures -
@neeraj-iAaNcG • Sep 11, 2012
Sure you can post your doubts one by one here and we can then interact.. Regarding advantages of C# over C++, there are a whole bunch of new concepts in c# compared to c++. Some of them are the likes of partial classes, delegates, events etc and a biggest advantage is garbage collection that makes the use of destructor out of the question. C# was developed by MIcrosoft to have direct competition with Java. So you can, in many ways consider C# to be in the league of Java -
@anoop-kumar-GDGRCn • Sep 11, 2012
Data structures are considered to toughest for beginners.. strange names, lots of algorithm and sudo codes.
But truth is , it seems interesting when you start relating data structures to day to day real things.
Every one have encountered with Stack, Queue, List, LinkedList blah blah... Aren't they?? -
@jeffrey-xA7lUP • Sep 12, 2012
can you guys explain traversing of a list -
@optimystix-at-gsBW56 • Sep 12, 2012
hey first refer the book of yashwant kanetkar "Data Structures Through C" even after rafering the book u have the query i will give u the java code of structures -
@anoop-kumar-GDGRCn • Sep 12, 2012
going to every item of list is traversing. Major use is find desired item in least time.jeffrey samuelcan you guys explain traversing of a list
For example: you got the shopping list how you fing a item from it. one way is just look for the item from top and go towards the bottom. -
@optimystix-at-gsBW56 • Sep 12, 2012
Traversing is more similar to searching of element in the list in least possible time u can use binary search tree for it it's best for searching
*binary search tree*
import java.io.*;
class node
{
int data;
node l;
node r;
public node(int i)
{
data=i;
l=null;
r=null;
}
}
public class bst
{
node root=null;
node head=null;
void create(node p,node temp)
{
if(temp.data<p.data)
{
if(p.l==null)
{
p.l=temp;
return;
}
else
{
create(p.l,temp);
}
}
else
{
if(p.r==null)
{
p.r=temp;
return;
}
else
{
create(p.r,temp);
}
}
}
void inorder(node t)
{
if(t!=null)
{
inorder(t.l);
System.out.println(t.data);
inorder(t.r);
}
}
void preorder(node t)
{
if(t!=null)
{
System.out.println(t.data);
preorder(t.l);
preorder(t.r);
}
}
void postorder(node t)
{
if(t!=null)
{
postorder(t.l);
postorder(t.r);
System.out.println(t.data);
}
}
public static void main(String[] args)throws IOException
{
DataInputStream input=new DataInputStream(System.in);
bst b=new bst();
int ch,item,n;
do
{
System.out.println("1-create");
System.out.println("2-inorder");
System.out.println("3-preorder");
System.out.println("4-postorder");
System.out.print("Enter your choice:");
ch=Integer.parseInt(input.readLine());
switch(ch)
{
case 1:
System.out.print("Enter n:");
n=Integer.parseInt(input.readLine());
for(int i=0;i<n;i++)
{
System.out.println("Enter the item:");
item=Integer.parseInt(input.readLine());
node temp=new node(item);
if(b.head==null)
b.head=temp;
else
b.create(b.head, temp);
}
break;
case 2:
b.inorder(b.head);
break;
case 3:
b.preorder(b.head);
break;
case 4:
b.postorder(b.head);
break;
}
}while(ch<=3);
}
} -
@vinod1993-r3yTlk • Sep 13, 2012
I am not able to visualise the use of pointers properly. for eg. I'm completely able to understand the array implementation of a stack but am not able to understand linked list implementation of stacks. Why? because, I am not able to visualise pointers properly. Please help me. 😀 -
@vishal-pysGmK • Sep 13, 2012
The best way to understand is the "paper and pen" method.vinod1993I am not able to visualise the use of pointers properly. for eg. I'm completely able to understand the array implementation of a stack but am not able to understand linked list implementation of stacks. Why? because, I am not able to visualise pointers properly. Please help me. 😀
Draw the diagram regarding the thing you are trying to do. You'll understand easily what you have to link.
This goes for all linked list programs. -
@simplycoder-NsBEdD • Sep 17, 2012
Linked Lists arent that tough(They are when they are introduced), but later they dont matter much.
First of all, its not mandate to visualize stack as a top to bottom array, where top is the place from where the elements are removed.
If I were to visualize stacks in linked list, I visualize it as train
where one bogie is connected to another.
Assume that engine is the top so when you want to remove a bogie, in stack fashion, you can remove it only from the engine side and then attach engine to the new bogie same thing when adding.
Now correlate this with address of top and engine, I think this picture will get you clear.
Look around, world is full of data-structures and algorithms. -
@simplycoder-NsBEdD • Sep 17, 2012
I don't quiet agree with the term 'least'(no offense) here as a good hash function will have O(1) time where as Binary tree search will have O(lg(n)) theoretically.optimystix@Traversing is more similar to searching of element in the list in least possible time u can use binary search tree for it it's best for searching
The issue with Hash Tables is that the memory required is higher than that of Binary Tree when we have large amount of data. So even if the search time in hashing is O(1), it will blast in space much higher as compared to Binary tree blasting in time when there are memory constraints.
But then theoretically, Hashing will give superior performance as compared to BST.