BigQuestion

BigQuestion - - Write to a fle every string you search For...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Review Session - Test 2 - Cumulative Question Library functions: 1. Defne a linked list and linked list node structure which contains a dynamically allocated string (hint: you'll need a length as well) 2. Write Functions to create, insert into, and search For nodes in the linked list 3. Write a Function to use rand() to generate a 3-character (lower-case alphabetic) dynamically allocated string Main: 1. Seed the random number generator with your birthday: 10000*year + 100*month + day 2. Generate random 3-character strings (using the Function you wrote) and insert them (as you create them) into your list. The more you generate, the higher the chance you have oF fnding it later. 3. Generate random 3-character strings and search For each until you fnd one that is in your list.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: - Write to a fle every string you search For on a new line 4. Display to the screen how many tries it took to generate a string that was Found. 5. ree the list using the Function you wrote and any strings you are still using. Things to watch out for/Questions to ask yourself: 1. What do you do iF the string already exists in the linked list? 2. When is it appropriate to Free the strings which are allocated For the purpose oF insertion? 3. When is it appropriate to Free the strings which are allocated For the purpose oF searching? Hints: 1. Generate a random number between low and high : int rand_val = rand()%(high-low)+high; 2. Create a character numerically char ch = 'a' + num;...
View Full Document

Ask a homework question - tutors are online