EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Question
Chapter 3, Problem 5PA
Program Plan Intro
Simple Line Editor
Program Plan:
- A linked list which containing the nodes of type string is used to store the lines of the line editor.
- Each line of the editor is saved in the each nodes of the linked list sequentially.
- The line editor will start with a command “EDIT”, the word followed by the “EDIT” command will treated as the file name.
- The command “I” is used to insert in the editor.
- If the command “I” is followed by a number, the next line will save at that specific line.
- If the insert comment “I” does not follow by any numbers, the next line will insert in the current position.
- The command “D” is used to delete the lines from the editor.
- If “D” is not followed by any numbers, then current line will be deleted.
- If “D” is followed by one number, the line at that specific number will be deleted.
- If “D” is followed by two numbers, then all the lines between those lines will be deleted.
- The command “L” is used to list the lines as the delete does.
- The command “A” will append the next line inserted to all the existing lines.
- The command “E” is used to save the lines to a text file and exit the editor.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Read a series of characters from standard input and keep them in a linked list so that there are no duplicates. Put a newly introduced character at the top of the list when you read it in. If you read a character more than once, remove it from the list and put it back in at the beginning. The well-known move-to-front method, which is beneficial for caching, data compression, and many other applications where objects that have been recently accessed are more likely to be reaccessed, is implemented by the programme MoveToFront.
A singly linked circular list is a linked list where the last node in the list points to the first node in the list. A circular list does not contain NULL pointers.
A good example of an application where a circular linked list should be used is an item in the shopping cart
In an online shopping cart, the system must maintain a list of items and must calculate the total bill by adding the amount of all the items in the cart,
Implement the above scenario using a Circular Link List of data structure in C++ Programming.
Do Following:
First create a class Item having id, name, price, and quantity provide appropriate methods and then Create Cart/List class which holds an items object to represent total items in the cart and next pointer Implement the method to add items in the array, remove an item and display all items.
Now in the main do the following
Insert Items in the list
Display all items.
Traverse the link list so that each item's bill gets calculated (by multiplying quantity with…
Write a program that reads information about employees of a company from a file. The information in the file is ordered based on the salary. An employee with the highest salary, for example, should appear at the top. Your program should first read the contents of the input file, create a linked list to store the contents, and then display the original list. Then, it will delete the employee with ID 444444444 from the list and will display the list again. The last step your program perform is to insert three new employees into the list and display the final results. Here is the information on the three new employees
Given:
Last Name First Name ID Phone Salary=========== ========== ======== ======= =====Wood Carpenter 333556666 222-222-2222 40000Ironman Iron 444444443 828-888-8888 73000Goal-keeper Martin 777777777 888-666-8888…
Chapter 3 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Ch. 3 - Prob. 1ECh. 3 - Prob. 2ECh. 3 - Prob. 3ECh. 3 - Prob. 4ECh. 3 - Prob. 5ECh. 3 - Prob. 6ECh. 3 - Prob. 7ECh. 3 - Prob. 8ECh. 3 - Prob. 9ECh. 3 - Prob. 10E
Ch. 3 - Prob. 11ECh. 3 - Prob. 12ECh. 3 - Prob. 13ECh. 3 - Prob. 14ECh. 3 - Prob. 15ECh. 3 - Prob. 16ECh. 3 - Prob. 17ECh. 3 - Prob. 18ECh. 3 - Prob. 19ECh. 3 - Prob. 20ECh. 3 - Prob. 21ECh. 3 - Prob. 22ECh. 3 - Prob. 23ECh. 3 - Prob. 24ECh. 3 - Prob. 25ECh. 3 - Prob. 1PACh. 3 - Prob. 2PACh. 3 - Prob. 3PACh. 3 - Prob. 5PACh. 3 - Prob. 7PA
Knowledge Booster
Similar questions
- write a function that add any item in a linked list after the item X, if the item X is not found in the linked list don't add the item. data structre please solve it fast less than 30 minutearrow_forwardIn this lab the task is to write a program that maintains a personal phone book. The program allows to: ▪ Add and Delete entries from the phone book, ▪ Search the phone book for a specific entry by last name or by phone number, and ▪ Print out the entire entries in the phone book. The data in the phone book is maintained by storing in memory with the use of a singly linked list, with one list node per entry. Each node contains members for storing a person’s family name, first name, address, and the phone number. Use strings to store this information. The linked list must be kept in increasing alphabetical order, sorted by family name. There are no duplicate entries with the same family name allowed in the phone book. This program should be menu driven, with the user being offered a choice of the following commands described below: ▪ Insert a new entry into the phone book. The program should prompt the user for a new family name and first name, an address and a phone number. This…arrow_forwardWrite a menu-driven program to create an unrolled linked list and retrieve,insert and delete an element from it. You may take liberties with the operationswhile implementing them.arrow_forward
- 4. Write a Python program to search a specific item in a singly linked list and return true if the item is found otherwise return false.arrow_forwardImplement an items stock system using your singly linked list from LAB 05: Exercise # 1 Add an item should input from user all the required data for an item and add the item in front of linked list using the method addToHead(). Remove an item should input itemID from user and delete it from the list using the method delete(itemID), if present. Show list of items should display the items in list using the method printAll(). Exit should close the program (running in infinite loop) using return or break statement . A node in this list should contain following information about items: class Item { public long itemID; public String itemName; public String manufacturer; public int version; public String countryOfOrigin; public int year; public Node next; public Node(long ID, String itnm, String manufac, int ver, String origin, int y) { itemID = ID; itemName = itnm; manufacturer = manufac; version = ver; countryOfOrigin…arrow_forwardWrite a program that lets the user enter numbersfrom a graphical user interface and displays them in a text area, as shownin Figure a. Use a linked list to store the numbers. Do not store duplicatenumbers. Add the buttons Sort, Shuffle, and Reverse to sort, shuffle, andreverse the list.arrow_forward
- Read in a sequence of characters from standard input and maintain the characters in a linked list with no duplicates. When you read in a previously unseen character, insert it at the front of the list. When you read in a duplicate character, delete it from the list and reinsert it at the beginning. Name your program MoveToFront: it implements the well-known move-to-front strategy, which is useful for caching, data compression, and many other applications where items that have been recently accessed are more likely to be reaccessed.arrow_forwardDevelop a program that will maintain an ordered linked list of positive whole numbers. Your program will provide for the following options: a. Add a number b. Delete a number c. Search for a number d. Display the whole list of numbers At all times, the program will keep the list ordered (the smallest number first and the largest number last). At the start of the program, the list will be empty. The user will add new numbers by choosing the "add" option and will supply the number to be included in the list. The program will add the number to the list at the appropriate position in the linked list so that the list will remain ordered. If the number being added is already in the list, the program will display a message: "Duplicate number. Not added to the list". This will ensure that the list does not contain any duplicate numbers. For removing a number from the list, the user will choose the "delete" option and supply the number to be removed. If the number is in the list, it will be…arrow_forwardThe programming language is Python Instructions: Create a function that will delete a node in a Linked List based on position number. On below example, if you want to delete position #2, it will remove the Banana (arrangement of nodes below is Apple, Banana, Cherry, Grapes, Orange). myLinkedList = LinkedList() myLinkedList.append("Banana") myLinkedList.append("Cherry") myLinkedList.append("Grapes") myLinkedList.append("Orange") myLinkedList.prepend("Apple") myLinkedList.deleteByPositionNum(2) node = myLinkedList.head while node: print(node.value, " ") node = node.next_node You may start with the function head:def deleteByPositionNum(self, positionNum):arrow_forward
- Write a program to insert 3 elements to locations x, y, and z into the linked list that has 20 elements (integer data type). x, y, and z are user input from the keyboard. The program needs to be written in C language and can be compiled on Omegaserver. Solution:arrow_forwardWrite a program in three parts. The first part should create a linked list of 26 nodes. The second part should fill the list with the letters of the alphabet. The third part should print the contents of the linked list. NOT USE malloc, only use <iostream>arrow_forwardFunction to add words from text file, without duplicate, using linked list (in C). input: something I I like like output: something I likearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education