Write a program in C++ that efficiently implements a skip list that holds integers. Your program...

80.2K

Verified Solution

Question

Programming

Write a program in C++ that efficiently implements a skip listthat holds integers. Your program should: 1. Accurately implementthe skip list ADT using a random number generator and nodes thatcontain an integer as well as the addresses of adjacent nodes tothe left, right, up, and down. 2. Correctly implement the Insert,Search, and Delete operations. 3. Read a series of unique,newline-delineated integers from a file and insert them (one at atime in the order provided) into your skip list. If the number ofnodes is not greater than 24 , print out the number of comparisonsfor each insertion, as well as the level at which each number isinserted (this should vary with each execution of your program!) 4.Repeat this process for each input file in sorted, “perfect”, andrandom order (these are the same input files you used forAssignment 4). 5. If the number of nodes is not greater than 24 ,print a representation of your skip list to the console. Note: asimple series of space-separated numbers for each level issufficient here. Overloading operator and usingnumeric_limits::max() and numeric_limits::min(). – The ctimelibrary (#include ) is helpful for random number generation. Usesrand(time(0)) to seed your number generator, and the rand()function to get your “coin flips.” Or you can use the C++ classrandom (#include ). – You may want your search function to return apointer/iterator to the item it finds (this can simplify yourdelete function); you may also have to pass your insert function aninteger by reference so that you can keep track of the comparisoncount. – In order to remove items from your skip list, simply callthe delete function using the numbers in the file (you can alsostore the numbers in a vector or somewhere when you read them in sothat you don’t have to read them in twice). DO NOT implement afunction that deletes arbitrary elements from the skip list!

Answer & Explanation Solved by verified expert
4.3 Ratings (605 Votes)
PLZ dont forget to give a thumbs up include using namespace std Class to implement node class Node public int key Array to hold pointers to node of different level Node forward Nodeint int NodeNodeint key int level thiskey key Allocate memory to forward forward new Nodelevel1 Fill forward array with 0NULL memsetforward 0 sizeofNodelevel1 Class for Skip list class SkipList Maximum level for this skip list int MAXLVL P is the    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students