SORTING WITH DOUBLY LINK LIST NOT BINARY SEARCH TREE. THIS ASSIGNMENT IS ALREADY SOLVED BY answers TEAM BUT ONLY FOR BINAR

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

SORTING WITH DOUBLY LINK LIST NOT BINARY SEARCH TREE. THIS ASSIGNMENT IS ALREADY SOLVED BY answers TEAM BUT ONLY FOR BINAR

Post by answerhappygod »

SORTING WITH DOUBLY LINK LIST NOT BINARY SEARCH TREE.THIS ASSIGNMENT IS ALREADY SOLVED BY answers TEAM BUT ONLY FOR BINARYSEARCH TREE. I WANT IT FOR DOUBLY LINK LIST. DO NOT COPY THEOLD CODE OF BINARY SEARCH TREES. DON'T WASTE TIME FOR IT. READINSTRUCTIONS CAREFULLY,
Assignment #1 Instructions: Sorting with A Doubly LinkedList
Through this programming assignment, the students will learn todo the following:
Know how to process command line arguments.
Perform basic file I/O.
Use structs, pointers, and strings.
Use dynamic memory.
This assignment asks you to sort the words in an input file (orfrom standard input) and print the sorted words to an output file(or standard output). Your program, called doublesort, will takethe following command line arguments:
% doublesort [-cd] [-o output_file_name] [input_file_name]
If -c is present, the program needs to compare the strings casesensitive. Otherwise, the program compares strings caseinsensitive. If the output_file_name is given with the -o option,the program will output the sorted words to the given output file;otherwise, the output shall be to standard output. Similarly, ifthe input_file_name is given, the program will read from the inputfile; otherwise, the input will be from the standard input. If the-d is present, the output will be in lexicographically descendingorder otherwise it will be in lexicographically ascending order.You must use getopt() to parse the command line arguments todetermine the cases and the order.
In addition to parsing and processing the command linearguments, your program needs to do the following:
You need to construct a doubly linked list as you read frominput. Each node in the list will link to the one in front of itand the one behind it if they exist. They will have NULL for theprevious pointer if they are first in the list. They will have NULLfor the next pointer if they are last in the list. You can look updoubly linked lists on the web or in your Data Structuretextbook.
Initially the list is empty. The program reads from the inputfile (or stdin) one word at a time; If the -c is present you woulduse the words as they are read in. If there is no -c then do thecomparison case insensitive where all capital letters are the sameas all lower case letters. Use capital letters to store the wordsand print them out.
As long as you continue reading words, if the word is notalready in the list, it should create a list node that stores apointer to the word and then insert the list node into its place inthe list. If the word exists, then do not create a node. Allduplicate words are ignored.
An empty line would indicate the end of input for stdin, an endof file would indicate the end of input for an input file.
You must develop a string comparison function. You must not usethe strcmp() and strcasecmp() functions provided by the C library.You must implement your own version. You will be comparing theASCII values. Note that using ASCII, all capital letters comebefore all lower case letters.
Once the program has read all the input (when EOF is returned ora blank line encountered), the program then performs a traversal ofthe doubly linked list either first to last as the default or ifthe -d option is present, last to first to print out all thestrings one word at a time to the output file or stdout. The outputwould be one word per line.
Before the program ends, it must reclaim the list! You can dothis by going through the list and freeing all nodes. This can bedone in either direction. Make sure you also reclaim the memoryoccupied by the string as well.
It is required that you use getopt for processing the commandline and use malloc or calloc and free functions for dynamicallyallocating and deallocating nodes and the buffers for the strings.It is required that you implement your own string comparisonfunction instead of using the corresponding libc functions.
Here's are some examples:
crahn@ocelot:~ 105% cat infile1
apple
apple
APPLE
APPLE
Apple
banana
BANANA
crahn@ocelot:~ 107% doublesort infile1
APPLE
BANANA
crahn@ocelot:~ 108% doublesort -c -o outfile1 infile1
crahn@ocelot:~ 109% cat outfile1
APPLE
Apple
BANANA
apple
banana
crahn@ocelot:~ 110%
crahn@ocelot:~ 108% doublesort -d -c -o outfile1 infile1
crahn@ocelot:~ 109% cat outfile1
banana
apple
BANANA
Apple
APPLE
crahn@ocelot:~ 110%
Please submit your work as one zip file. Follow the instructionsbelow carefully (to avoid unnecessary loss of grade):
You should submit the source code and the Makefile in the zipfile called FirstnameLastnameA1. One should be able to create theexecutable by simply 'make'. The Makefile should also contain a'clean' target for cleaning up the directory (removing all objectfiles at a minimum). Make sure you don't include intermediatefiles: *.o, executables, *~, etc., in your submission. (There'll bea penalty for including unnecessary intermediate files). Only twofiles should be included unless permission is given for more, thosewould be doublesort.c, and Makefile. If you feel a need to includea .h file written by you, please send me a note with a copy of thefile asking for permission
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply