Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USE REQS IN THE LAST PICUTRE FOR PROGRAM Description You are required to write an interactive C program that prompts the user for commands, accepts

image text in transcribed

USE REQS IN THE LAST PICUTRE FOR PROGRAM

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed Description You are required to write an interactive C program that prompts the user for commands, accepts commands from the keyboard (stdin and executes those commands. When a command requires output, it must be written to stdout, The program must continue to accept and process commands until the user types the end command. The program deals with linked lists. Each node of such a list contains a string of length at most 10, a positive integer (i.c., an integer value 1) and a pointer to the next node of the list. For any node, the string and the integer stored in that node will be referred to as the symbol and count for that node respectively. At all times, the list must satisfy the following two important properties. 1. The symbols appearing in the list are all distinct; that is, no two nodes have the same symbol. 2. When the list is scanned from left to right, the counts must be in non-increasing order. An example of such a linked list is shown below. Initially, we have an empty list. Some commands require your program to modify the list while others involve traversing the list to gather and print information about the list. The commands and their interpretations are as follows Vou should bear in mind that different parts of a command are separated by one or more spaces.) A. Insert Command: The syntax for this command is as follows: ins str Here, ins represents the name of the command and sta represents a string. The interpretation of this command is as follows. (a) If the list contains a node whose symbol is identical to the string specified in the command, then the count stored in the node must be incremented by 1. After this increment, if necessary, the node must be moved to an appropriate position in the list to ensure that the counts are in non increasing order. (b) If the list does not contain a node whose symbol is identical to the string specified in the command, then a new node must be created. The symbol stored in the new node is the string specified in the command and the count stored in the new node must be 1. The new node must be nserted at the en d of the st. Note that the ins command does not produce any output

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago