Complete IIT AIEEE ICSE ISC PMT help forum
This is a free help Forum for Indian Students.
Complete IIT AIEEE ICSE ISC PMT help forum

Complete help forum for students preparing for icse iit aieee cbse pmt and other related exams.Stay updated about all 2011 exams.
 
HomeHome  PortalPortal  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  India NewsIndia News  
Keywords
RESULT papers CLASS question YEAR prelim 2010
Latest topics
Top posters
abhas
 
Anu..i luv icse...:)
 
G-7
 
siya
 
Candy
 
jOhNy
 
Apurva
 
WinRrule
 
ambili
 
saif
 



Search if you can't find it here

algorithms in simple data structures..??

View previous topic View next topic Go down
Go to page : 1, 2  Next
AuthorMessage
sim27in

avatar


PostSubject: algorithms in simple data structures..?? Thu Mar 18, 2010 10:34 pm

does ny1 hv easier algortihms of push,pop....etc...coz d ones in sumita arora r kinda difficult to understand....???
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 10:37 pm

To be frank to u brother...those ar the easiest..! trust me..!
Back to top Go down
View user profile
sim27in

avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 10:40 pm

ohk...firstly...im a gal...

well...then...bro if they r d easiest....
cn u try n explain ny 1 of dem...??
id be grateful...
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 10:59 pm

eh..? sorry.. i didnt bother to chck ur profile..cuz..im..er..anyway.,..sorry..!

I'll explain the Deletion in a Stack - popping.
If we consider an array of max N elemnts. First we initialise the control variable ctr to top.

ctr = top;
and w're printing the element.now there is a vacant pos at the top. as the elements are poped out frm the top. Now we are pulling the second element to th top and the other elements to the positon just aboove them.

Stack[ctr]=Stack[ctr++]

thats all...!!

If u can undrstand this try using the same mode of thought and try to understand the others too.! If u get any doubt juz ask me.
Back to top Go down
View user profile
sim27in

avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:04 pm

ohk...dis seems easy...
thx nyway....

n wats d diff btw deletion in a stack(as an array)....n deletion in a stack(as a linkd list)..??
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:12 pm

You know array is contigous...while a linked list is "linked"..! One node's link part referenced to the Data part of the next one. There are no top or bottom in LL..only last and first. So...if we are deleting ANY node, which we cannot do in Stack Array...! In that LIFO principle is followed. Last In First Out...adn if u want to pop out the middle element u have no way but to pop out all the elements above it.!

But in LL, u can delete any node irrespective of its' position and after u delete a node u have to link the node preceding the deleted node to the node succeeding the deleted node.!!

Thats just a simple differece.

Any more? Im going to take my dinner. I'm starving. So.will be back after 15 mts.

bye


Peace..!
Back to top Go down
View user profile
sim27in

avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:14 pm

ya...ok...hv ur dinner..
till den ill try to understand it...
thx..!
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:30 pm

Hi..!
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:36 pm

hey guyzz...howzz the preparations for computer going on.......as for me, I'm getting screwed by section C......
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:37 pm

Quite well...! What are u getting pinned at..??
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:39 pm

linked lists........
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:40 pm

Hey man can u check a program on deque for me ??....the one given in the sample paper...
here it is....on my own logic.....

class chain
{ int ele[];
int cap,front,rear;
chain(int max)
{ cap=max;
front=0;rear=0;
ele=new int[cap];
}
void pushfront(int v)
{ if((front>0)||(front==0&&rear==0))
{ ele[--front]=v;
}
else
{ System.out.println("Full from front");
}
}
int pop()
{ if(front==0&&rear==0)
{ return 999;
}
else
{ ++front;
return(ele[front-1]);
}
}
void pushrear(int v)
{ if(rear==cap-1)
{ System.out.println("Full from rear");
}
else
{ ele[++rear]=v;
}
}
int poprear()
{ if(front==0&&rear==0)
{ return 999;}
else
{ --rear;
return(ele[rear+1]);
}
}
}
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Thu Mar 18, 2010 11:48 pm

i found a bug in the initial part.

void pushfront(int v)
{ if((front>0)||(front==0&&rear==0))
{ ele[--front]=v;
}

if front = rear = 0 ie one element in deque then ele[-1]would be initialised to v..?

a negative index would cause a runtime exception...
Back to top Go down
View user profile
sim27in

avatar


PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:00 am

hey wat progs do u think r important...??
r inheritance,recursion,linkd list progs sure to come...??
or wud it be easy like previous years..??? ny idea...???
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:01 am

ur right....here's a new version of the pushfront()

void pushfront(int v)
{ if(front>0)
{ ele[--front]=v;
}
else if(front==0&&rear==0)
{ ele[0]=v;}
else
{ System.out.println("Full from front");
}
}
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:03 am

is the pop part okk dude ??
@ sim27:inheritance and recursion are definitely coming...hope the paper's gonna be easy....only time will tell.....
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:04 am

i really pray that it wud be easy..! but nothng cud be taken for granted. I am not blindly expecting anythng....just hoping that whatever it is...i can do it..!!!

anyway..all the best everybody...!
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:05 am

gimme a little more time...!! im checkng..!
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:06 am

the pop part has a little problem....just that it's not popping.....lolzzz...gotta check that out......
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:08 am

yeah man sure !!!
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:10 am

dude..tha same part...what happens to the original ele[front] when u push a new one..???

it gets ovr written ... doesnt it..? and still there remains only one element. which contradicts the case that the deque shud get longer as we add elements...
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:12 am

hey the program's working cool...I just finished checking......actually when I was printing I forgot to take front and rear as the lower and upper limits and was rather printing the whole array out....stupid me !!! .....newayzz....lemme know if you find some mistake....cheers !!!....at last it seems I'm getting into 'queues'......
Back to top Go down
View user profile
diptojit
Active member
Active member



PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:15 am

nawhh it's not getting overwritten...I'm not shifting elements here...I'm just changing the front and rear index...and when the front is full there can't be any addition in the front...that happens in a stack.....this is a deque..isn't it ??
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:16 am

dude.. the pop part doesnt work because the push part is not correct.. there is only one element all the time in the deque...and also when u r poping u r not printin the value but 999

if(front==0&&rear==0)
{ return 999;

only this part is repeating as there is only one element..and the reason is cited ealier in this post..!
Back to top Go down
View user profile
G-7
Active member
Active member
avatar


PostSubject: Re: algorithms in simple data structures..?? Fri Mar 19, 2010 12:18 am

thre are two types of deque...input controlled and outpput controlled...

the input restricted only allows isertion at one end but deletion at both ends...

but the output restricted allows deletionat one end only and insertion at both ends..!

urs is wich type..?
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: algorithms in simple data structures..??

Back to top Go down

algorithms in simple data structures..??

View previous topic View next topic Back to top
Page 1 of 2Go to page : 1, 2  Next

Permissions in this forum:You cannot reply to topics in this forum
Complete IIT AIEEE ICSE ISC PMT help forum :: ISC :: ISC 2010 [Class xii] :: Computer-