Learn

Dr. Shah is a busy surgeon. He sees so many different patients every day that it’s often hard to keep track which patients have which diseases. He decided to store this data in some of the cool data structures he learned about. However, because he never learnt asymptotic notation, he didn’t know which data structure would be the fastest. He decided to store his patient data in both a HashMap and a Linked List.

In the HashMap, he stored the values as key value pairs where the patient’s name is the key and the respective patient’s disease is the value.

In the Linked List, he made each node a list of two values: the first value is the patient’s name and the second value is the patient’s disease.

In this exercise, you will select patient data from both the HashMap and Linked List and compare which one is faster.

Instructions

1.

Change the value of hashmap_zachary_disease to Zachary’s disease according to the HashMap. DO NOT simply write "Sunburn Sickness". Use the HashMap methods to extract the value.

2.

Given that N is the size of the HashMap, change the value of hashmap_runtime to the big O runtime of getting a value from a HashMap. Select from the following options:

  • "1"
  • "N"
  • "log N"
  • "N log N"
  • "N^2"
  • "2^N"
  • "N!"
3.

Change the value of linked_list_zachary_disease to Zachary’s disease according to the Linked List. DO NOT simply write "Sunburn Sickness". Write code that uses the Linked List and Node methods to extract the value.

4.

Given that N is the amount of Nodes in the Linked List, change the value of linked_list_runtime to the big O runtime of getting the first value added to the Linked List. Select from the following options:

  • "1"
  • "N"
  • "log N"
  • "N log N"
  • "N^2"
  • "2^N"
  • "N!"

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?