Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board
Go4Expert
Go4Expert RSS Feed

Go Back   Programming and SEO Forum >  Go4Expert > Queries and Discussion > Programming > C-C++

Reply  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More
 
Bookmarks Thread Tools Search this Thread Display Modes
Old 08-21-2007, 12:59 PM   #1
Newbie Member
 
Join Date: Aug 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
priya7 is on a distinguished road

Wanted C programmes for these problems


Stacks and Queues for Day Two:
Stack is abstract data type where elements inserted into stack using push model
until entire stack is full. Elements/values can be removed using pop operation
until entire stack is empty. This is a data type where last inserted elements are
removed first.
Stacks can be implemented in multiple ways, since stacks are considered
abstract there is no implementation of stack data type in C or C++ (java does
have a stack data type).
There are many applications of this stack in day to day life. All the operations
which do not have conditions like time frame or costs are executed using stack
data structure.
Toy Problem for Stacks:
Let us implement stacks in C. We need to create user defined data type called
stack. Also we need to create operations involving around this stack. We might
as well create stacks using arrays but how do we remove a memory location?
So this task implementing stacks using Linked Lists (Structure). Create linked
list structure. Let us call the linked list as stack which can be represented with
following structure:
Create functions called push and pop. Notice when we insert an element into
stack (top element) we are basically inserting values in first node. When we pop
an element from stack we are removing element in the first node. Please be
careful about memory allocation and handling the first node.
Task on Stack Data Structure:
Write a C program to calculate total sales and report transactions done by a coke
vending machine. Soft drink (coke) tins are added into the vending machine one
on top of the other. Each tin contains batch number, tin number, price for each
tin. Money is accumulated when users buy the coke tins. Usually the tins on top
are dispensed. Machine would no longer accept currency when stack is empty.
typedef struct StackDataStructure{
int value;
struct StackDataStructure *nextStackElement;
}Stack;
1. Print out price, batch number and tin number when a can is popped out of
machine.
2. Push method would add values of batch and tin number to the stack.
3. Calculate total sales.
Queue:
Queue is another abstract data structure which works exactly like a stack. In real
world applications queues are mostly time bounded, so first come person/job
gets served first like queue in banks, queue to board a train etc. The first person
is called front of the queue (the most likely person to get served) and the last
person is called rear.
Just like stack a queue does not have data type in C or C++ (java on other hand
has queue implementation in the language).
Toy problem on queue:
Let us create user defined data type in C using structures; we try to implement
queues using linked lists.
Create front and rear nodes. Initially when both front and rear nodes are NULL
that means queue is empty. When we insert elements in queue front becomes
the first node (for the first element rear is equal to front). More elements are
added to the queue as rear. Deletion/Pop operation happens only to from
element.
Write a C program to implement above mentioned scenario.
Task on Queue:
When was the last time you visited a railway reservation counter? Assuming the
south central railway decides to stream line their customer management at
reservation counters (so that all the passengers get equal and right full services).
They decided upon a token system where users are required to collect token
when they enter reservation office. Multiple counters in the reservation office
would display token numbers on LCD/monitor corresponding to the counter.
typedef struct QueueDataType{
int value;
struct QueueDataType *nextQueueElement;
} Queue;
Separate counters are installed for ladies, senior citizens and people with
payments using credit cards. During token collection user chooses between L,
S, C, and G options corresponding to ladies, senior citizens, credit card payers
and general/other passengers.
Each teller at a counter has next button, upon press the system should display
next token number based on token collected by the passengers. Software
should be able to deploy any where in the country only variable factor here is
number of counters. Bigger the station, higher the number of counters. Stations
with fewer counters can combine L/S/C into one option (called S means special).
How to solve?
1. Write a structure to handle counter related information as
follows:
2. Set initial counter values like G001 (general), L001 (ladies), S001
(seniors), C001 (credit cards) or SP001 (for special) as token numbers.
3. When the tokens are generated they are added to queue. We should need
separate queues based on number of special counters (of smaller stations
they might need only two queues; one for general and other for special).
4. Numbers of queues are not proportional to number of counters. Consider
scenario of four counters for general and one counter for special.
5. Create structure for counter. Each counter can be represented as variable
for this structure:
typedef struct RailwayCounter{
char currentToken[10]; //token number
char counterType; // l,g,c,s
}Counter;
typedef struct Station{
int numberOfCounters;
int enableLadiesCounter; //0 or 1
int enableSeniorsCounter; //0 or 1
int enableCreditCardCounter; //0 or 1
int enableSpecialCounter;
/* 0 or 1 special is enabled only when other privileged counters are combined. */
} ReservationOffice;
6. Based on number of counters in ReservationOffice we create Counter
variables.
7. Write method called char* nextToken(Counter c); which will return next
token number from the queue.
8. At the end the program should log all the token numbers inside a file with
tab as delimiter.
9. Deliverables for this program would be:
a. Methods to create a new reservation office
b. Methods to choose and add passenger choice in the main queue
program.
c. Queue program to manage and dispense token numbers to
appropriate counters.
d. Managing special/ladies etc. queues separately
e. Store all the counter information into a file.
Evaluation Criteria:
1. Toy Problem in stacks 15%
2. Task on stacks 35%
3. Toy Problem in queue 10%
4. Task on queue 40%
priya7 is offline   Reply With Quote
Old 08-21-2007, 01:34 PM   #2
Go4Expert Member
 
Join Date: Jun 2007
Location: Chennai
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
seeguna is on a distinguished road

Re: Wanted C programmes for these problems


hi ,
Go thru the C/C++ programming forum, it contains Stack and Queue implementation using Linked list(otherwise search the topic and go thru the article)

After went thru it , u can change it according to ur need........
If u face any error discuss with us.........

Try it of ur own........U can......
seeguna is offline   Reply With Quote
Old 08-21-2007, 02:55 PM   #3
Go4Expert Founder
 
shabbir's Avatar
 
Join Date: Jul 2004
Location: On Earth
Posts: 12,714
Thanks: 119
Thanked 293 Times in 227 Posts
Rep Power: 10
shabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud ofshabbir has much to be proud of
Send a message via Yahoo to shabbir

Re: Wanted C programmes for these problems


You need to be doing your homework and it would not take you far to hire someone for this.
shabbir is offline   Reply With Quote
Old 11-30-2007, 07:28 AM   #4
Newbie Member
 
Join Date: Nov 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Dean_X is on a distinguished road

Re: Wanted C programmes for these problems


Shout out to shabbir. Go back home....the taliban need you.
Dean_X is offline   Reply With Quote
Reply  Copy HTML to Clipboard  Copy BBCode to Clipboard  | More


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Bookmarks

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads / Articles
Thread Thread Starter Forum Replies Last Post
100 Multiple choice questions in C coderzone C-C++ 115 09-02-2010 03:29 AM
Overview of C# Sanskruti C# 2 09-23-2009 09:00 PM
Data Types in C# pradeep C# 20 02-21-2008 10:18 AM
Problems with strings in C TheCaptain22 C-C++ 5 05-03-2007 02:22 AM
error in compilation of binary tree code in c rahul_2550 C-C++ 9 03-26-2007 10:31 AM

 

All times are GMT +5.5. The time now is 04:09 AM.