Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   Circular linked list (http://www.go4expert.com/articles/circular-linked-list-t1282/)

Peter_APIIT 1Dec2008 07:59

Re: Circular linked list
 
Array is random access.

How can it be circular array A?

xpi0t0s 1Dec2008 13:29

Re: Circular linked list
 
Random access and circularity are not mutually exclusive.

back from retirement 3Dec2008 21:16

Re: Circular linked list
 
Excuse me....what I wanted to mean is that we can design a stack or a queue through array implementation. Can we do the same for doubly linked list or circular linked list???

xpi0t0s 3Dec2008 22:08

Re: Circular linked list
 
Probably, but the point of linked lists is that they're dynamic in size, whereas an array is a static size. Why would you want to implement a linked list with an array? (I can think of a reason but I'd like to hear your reason.)

back from retirement 5Dec2008 11:05

Re: Circular linked list
 
Nothing....just interested....I know that array is static....in that case, in the initialisation function, we will take an array of nodes....
And then follow the latter functions as usual...initial no. of nodes will be determined, I mean asked from the user, with their data as well....
But, it is really difficult....I am trying and trying....if I succeed, I will post it in a new article...

skp819 3Feb2009 11:10

Re: Circular linked list
 
It is good post. But when i run it occur some error.
but it is good commented and explain every thing in nice way which is easy to understand.

shabbir 3Feb2009 14:02

Re: Circular linked list
 
What kind of error ?

harris 3Mar2009 11:38

Re: Circular linked list
 
Quote:

Originally Posted by shabbir (Post 42357)
What kind of error ?

Well, it seems like the DO while is not working properly.. When i enter y after 'do ya want to continue' it's forever looping...

btw, shabbir, i need your help on this assignment...

Task

Write a program (YourName_queue.cpp) to implement a circular queue (max 5) to capture the taxis in a queue. Program should maintain the following information:

> License Number (max. 7 characters)
> Driver Name (max. 20 characters)
> Taxi Type (ie Comfort, CityCab, SMRT, Premier, Transcab)

Write a main program that display a menu of choices for user to perform the queue operations. You are to use an appropriate data structure to meet all requirements. Your program shall provide the following functions:

QUEUE OPERATIONS
1. Initialize queue
2. Insert a taxi at back of queue
3. Remove a taxi in front of queue
4. Count number of taxis in queue
5. View all taxis in queue
6. View taxi types in queue
7. Is queue empty?
8. Is queue full?
9. Quit

Functional requirements
1. Initialize queue. This option initializes/clears all items in the queue.
2. Insert a taxi at back of queue. If the queue is not full, program will prompt user to enter the taxi license number. It checks if the taxi already exists in queue. If yes, display error message, else prompt user to enter other taxi’s info and insert into the queue.
3. Remove a taxi in front of queue. If the queue is not empty, program will delete the taxi in front of the queue.
4. Count number of taxis in queue. This option will display the total number of taxis in the queue.
5. View all taxis in queue. This option will display all the taxis’ info in the queue, starting from the first taxi in front of the queue to the last taxi at the rear of the queue.
6. View taxi types in queue. This option will display the breakdown of the taxi types in the queue, ie the number of Comfort, CityCab, SMRT, Premier & Transcab. Assignment 3 Page 2
7. Is queue empty? This option checks whether the queue is empty and print an appropriate message.
8. Is queue full? This option checks whether the queue is full and print an appropriate message.
9. Quit. End the program.
Note: You can assume user will always start the program and initialises the queue (i.e. invoke option (1) first prior to any operations.

If ya got free time, try this program.. thanks..

shabbir 3Mar2009 12:16

Re: Circular linked list
 
I don't do other peoples school assignments and also please do not jump into any thread with your assignment and if you want some help with the assignment like you are stuck somewhere you can post as separate threads and we can help you out.

harris 3Mar2009 13:11

Re: Circular linked list
 
Quote:

Originally Posted by shabbir (Post 43757)
I don't do other peoples school assignments and also please do not jump into any thread with your assignment and if you want some help with the assignment like you are stuck somewhere you can post as separate threads and we can help you out.

Well, i don't usually pop out with this kind of thing but i need it urgent and using blood dev C is really pain in the ar5e.. i tried your progam but it's not working, something is wrong with your do while statement, it's infinite loop..


All times are GMT +5.5. The time now is 01:16.