Complete the code to declare an array of integers with 5 elements.
int[] numbers = new int[[1]];The correct syntax to declare an array of 5 integers in C# uses square brackets with the size inside: [5].
Complete the code to create a new node for a singly linked list in C#.
Node newNode = new Node([1]);When creating a new node, you pass the data value, here the integer 5.
Fix the error in the linked list traversal code by completing the blank.
while (current != [1]) { Console.WriteLine(current.Data); current = current.Next; }
The traversal should continue until current is null, which means the end of the list.
Fill both blanks to create a dictionary that maps array indices to linked list nodes.
Dictionary<int, Node> map = new Dictionary<int, Node>(); for (int i = 0; i [1] array.Length; i++) { map.Add(i, [2]); }
The loop runs while i < array.Length. The map adds the index i and the node at that index from the linked list using GetNodeAt(i).
Fill all three blanks to create a method that compares memory layout sizes of an array and a linked list.
public void CompareMemory(int[] arr, Node head) {
int arraySize = sizeof(int) * [1];
int nodeSize = (sizeof(int) + sizeof(IntPtr)) * [2];
Console.WriteLine("Array size: " + arraySize + ", Linked list size: " + [3]);
}The array size is the size of int times the array length. The linked list size is the size of Node times the number of nodes counted by CountNodes(head). The output prints both sizes.
