Input (from stdin): A text consisting of two lines of words in the following format: + line 1: the first line of words, separated by a white space. + line 2: the second line of words separated by a white space. + note that the last line does not contain \n' Requirement: + use a binary search tree to store the words on the first line, each in a node. + the tree follows the order that the word at a node alwavs appears before the word at its right

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Problem Description: Write a C program to do the following
Input (from stdin): A text consisting of two lines of words in the following format:
+ line 1: the first line of words, separated by a white space.
+ line 2: the second line of words separated by a white space.
+ note that the last line does not contain In'
Requirement:
+ use a binary search tree to store the words on the first line, each in a node.
+ the tree follows the order that the word at a node always appears before the word at its right
child node and after the word at its left child node, according to the dictionary (alphabetical)
order. You can use function strcmp(.) to compare strings.
+ after the tree is built, delete all the nodes storing the words on the second line. The lower
case and upper case of a character are considered the same (e.g., "hi" and "Hi" and "HI" are
considered identical).
Output (to stdout): two lines of text, all converted to lower case
+ line 1: the original words in the alphabet order, separated by single white space
+ line 2: the remaining words (after deletions), separated by single white space, in the order
they appear original on line 1 of the input text
Hint: you should create a struct for each node of the tree with the following attributes:
+ the word that is stored
+ the position of the word in the original text input's line 1
+ the pointers for the left and right children of the node
Examples:
Input1
hello world 123
world
Outputl
123 hello world
Transcribed Image Text:Problem Description: Write a C program to do the following Input (from stdin): A text consisting of two lines of words in the following format: + line 1: the first line of words, separated by a white space. + line 2: the second line of words separated by a white space. + note that the last line does not contain In' Requirement: + use a binary search tree to store the words on the first line, each in a node. + the tree follows the order that the word at a node always appears before the word at its right child node and after the word at its left child node, according to the dictionary (alphabetical) order. You can use function strcmp(.) to compare strings. + after the tree is built, delete all the nodes storing the words on the second line. The lower case and upper case of a character are considered the same (e.g., "hi" and "Hi" and "HI" are considered identical). Output (to stdout): two lines of text, all converted to lower case + line 1: the original words in the alphabet order, separated by single white space + line 2: the remaining words (after deletions), separated by single white space, in the order they appear original on line 1 of the input text Hint: you should create a struct for each node of the tree with the following attributes: + the word that is stored + the position of the word in the original text input's line 1 + the pointers for the left and right children of the node Examples: Input1 hello world 123 world Outputl 123 hello world
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY