Question
Create the following classes in C++. 1. Class 'lfsr' contains the following properties: a) An unsigned integer called the 'seed': (the seed value will range
Create the following classes in C++. 1. Class 'lfsr' contains the following properties: a) An unsigned integer called the 'seed': (the seed value will range between 0 to 255) b) A reciprocal characteristic/feedback polynomial function: (the user will set the characteristic polynomial. Basically, the user will specify the bit-positions which your class will use to generate the random numbers. The bits in the LFSR state that influence the input are called taps. An example of such function is given at page #04) Add appropriate member-functions such as, a) Constructor(s) b) A function to print the seed and generated numbers (both in integer and binary number system). c) A function (named as random_number_generator) to create 20 consecutive random numbers from the given seed and the characteristic polynomial. d) Based on the requirements of the class, you might have to convert any given decimal number to a binary number and store it. So, you need to implement a function that converts a given decimal number to a corresponding binary number. 2. Class binary_search_tree contains a root node of following type: struct tree_node { int data; struct tree_node *left_node; struct tree_node *right_node; } condition: _ > < _ > < _ > Add appropriate functions to - a) initialize the root b) grow the tree (insert new node) when a new number appears (the tree should not have any duplicate) c) print the tree using in-order traversal d) print the height of the tree e) print the height of any node f) print the degree of any node g) print the leafs of the tree h) print the root node of the tree i) delete any node from the tree j) search any node and print the height, degree, and parent of the node (if found!) Write a separate file "program_03.cpp" where, 1. You will read an integer and the characteristic polynomial from console/file (file redirect option). The integer will be used as a seed. You will call proper functions from LFSR object to use the seed and polynomial function to generate 20 random numbers. 2. Use these numbers to create and grow the binary search tree. 3. Call print functions of binary_tree (c~h) to show the corresponding outputs. 4. Call the delete function to delete any node and print the resultant tree. 5. Search any node and print some information (j) about the search-key. Sample Input: 105 4 5 3 2 0 Here 105 is the seed. The first value 4 (in the second line of input) tells that the polynomial contains 4 tap bits. And the bits are 5, 3, 2, and 0. Files: 1. class: lfsr --> class definition (.h) and corresponding class declaration file (.cpp) 2. class: binary_search_tree -->class definition (.h) and corresponding class declaration file (.cpp) 3. program_03.cpp (a file that contains the main function) 4. README (a file that explains how to compile/test your code + proper declaration of each class) Grading: There will be at least 6 files. Point Distribution: Class/File lfsr Class Binary_search_tree Class README program_03.cpp Points 15 65 10 10 i. Constructor: 05 ii. Random Number Generation: 10 i. Insert: 10 ii. Delete: 15 iii. Search: 10 iv. Print: 5 * 6 How to compile + 3 Sample I/O Implement all possible cases (1~5) Penalties: a. Code does not compile/run in CSE -100 b. Code does not compile/run in CSE, but it works in your local machine, report it in README. In such case, try to see the graders so that they can test your code and give you partial credit. If you fail to contact then, condition (a) will be applied to you. If you successfully demonstrate the output to the GRADERs, you will get credits <= 90 based on your implementation. c. Missing lfsr class -15 d. Missing binary_search_tree -90 (without this class none of the tree operations can be implemented) e. The tree contains duplicates -10 f. If you use any STL/Array/MAP/Vector -60 g. If you fail to implement lfsr and use the random number generator, but do not mention in the README -40 h. SEGMENTATION fault -20 i. PLAGIARISM Detected -100 & REPORT j. If you include any .cpp file in program_03.cpp -10 for each class. k. If you forget to place all necessary files in a single directory -10 Linear-feedback shift register In computing, a linear-feedback shift register (LFSR) is a shift register whose input bit is a linear function of its previous state. The most commonly used linear function of single bits is exclusive-or (XOR). Thus, an LFSR is most often a shift register whose input bit is driven by the XOR of some bits of the overall shift register value. Assume: current value = 110111012 = 22110 Linear function = (5, 3, 2, 0) given number: 110111012 //221 ((01)1)1) ======== 111011102 //238 ((11)1)0) ======== 111101112 //247 ((10)1)1) ======== 111110112 //251 ((11)0)1) ======== 111111012 //253 ((11)1)1) ======== 011111102 //126
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started