Waste less time on Facebook — follow Brilliant.
×

Linear Data Structures

This is putting your ducks in a row, Computer Science style. Some of the simplest but most useful data structures are linear. Dive in to build your foundational toolkit!

Linked Lists - Basic

Write a program to remove duplicates from an unsorted singly linked list.

How many elements will remain when all duplicates are removed from the linked list below.

32 - 16 - 90 - 13 - 0 - 80 - 20 - 92 - 77 - 77 - 25 - 9 - 73 - 100 - 63 - 55 - 34 - 17 - 17 - 74 - 83 - 59 - 39 - 9 - 53 - 52 - 84 - 63 - 34 - 46 - 25 - 85 - 7 - 43 - 18 - 94 - 34 - 53 - 61 - 7 - 76 - 33 - 95 - 65 - 30 - 90 - 84 - 72 - 0 - 88 - 17 - 95 - 58 - 81 - 100 - 72 - 66 - 87 - 43 - 24 - 6 - 5 - 82 - 62 - 93 - 86 - 54 - 88 - 59 - 61 - 2 - 92 - 40 - 83 - 82 - 25 - 60 - 38 - 58 - 21 - 62 - 12 - 13 - 98 - 48 - 56 - 100 - 78 - 83 - 61 - 81 - 66 - 72 - 39 - 75 - 45 - 26 - 81 - 59 - 91

Write a program that returns the middle node of an unsorted linked list. What is the middle node of the following linked list?

32\(\rightarrow\)16\(\rightarrow\)90\(\rightarrow\)13\(\rightarrow\)0\(\rightarrow\)80\(\rightarrow\)20\(\rightarrow\)92\(\rightarrow\)77\(\rightarrow\)77\(\rightarrow\)25\(\rightarrow\)9\(\rightarrow\)73\(\rightarrow\)100\(\rightarrow\)63\(\rightarrow\)55\(\rightarrow\)34\(\rightarrow\)17\(\rightarrow\)17\(\rightarrow\)74\(\rightarrow\)83\(\rightarrow\)59\(\rightarrow\)39

Given an unsorted singly linked list and an integer index, write a program that outputs the value of the node at the designated index position. For the linked list below what number is on the index position \([17]\)?

32\(\rightarrow\)16\(\rightarrow\)90\(\rightarrow\)13\(\rightarrow\)0\(\rightarrow\)80\(\rightarrow\)20\(\rightarrow\)92\(\rightarrow\)77\(\rightarrow\)77\(\rightarrow\)25\(\rightarrow\)9\(\rightarrow\)73\(\rightarrow\)100\(\rightarrow\)63\(\rightarrow\)55\(\rightarrow\)34\(\rightarrow\)17\(\rightarrow\)17\(\rightarrow\)74\(\rightarrow\)83\(\rightarrow\)59\(\rightarrow\)39

NOTE

The index position starts with a \(0\).

×

Problem Loading...

Note Loading...

Set Loading...