An array is a collection of elements of the same data type stored in contiguous memory cells . It has a fixed size and is by default passed by reference to a function. Eg. int arr[6] = {4, -3, 8, 5, -1, 6}; It initializes an integer array 'arr' storing 6 elements. Assuming the size of an integer to be 4 bytes and base cell address to be 2000. It can be represented as - A dynamic array is similar to a static array but it has the ability to automatically resize itself when an element is inserted or deleted. They are available as vectors in C++ and likewise l ists in Java . Eg. list<int> l; vector<int> v; Vectors are slightly less efficient than static arrays due to the occasional resizing and copying of elements. The amortized time complexity of insertion in a dynamic array is O(1). [Amortized Time complexity ...
A router is a networking device that forwards data packets from one network to another network based on their IP addresses. It is essentially a gateway to another network. It operates at the network layer(Layer 3) of the OSI reference model. When a data packet is received from the sending router, the receiving router inspects the packet's destination IP address and determines if the packet was made for its own network or another network. If the data packet is made for its own network then it receives it, if it is made for another network then it forwards the data packet to the destination network. The router makes use of the information present in the routing table. While Hubs and switches are used to create a network , routers are used to connect networks .