InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Write a program for reversing each word in a string. |
|
Answer» We will make use of a stack for pushing all letters until a space is found in a given string. When space is encountered, we will empty the stack and the reversed word will be printed with a space at the end. This process will be continued until the end of the string has been reached. // C++ program#include <bits/stdc++.h>using namespace std;// Reverses each word of a stringvoid reverseEachWords(string s){ stack<char> stk; /* TRAVERSES the given string and all the characters will be pushed to stack until a space is found. */ for (int i = 0; i < s.length(); ++i) { if (s[i] != ' ') stk.push(s[i]); else { // Contents of the stack will be printed when a space is found. while (stk.empty() == false) { cout << stk.top(); stk.pop(); } cout << " "; } } // As there may not be space after last word. while (stk.empty() == false) { cout << stk.top(); stk.pop(); }}int main(){ string s = "Welcome To InterviewBit"; reverseWords(s); return 0;}emocleW oT tiBweivretnIConclusion:The Cisco INTERVIEW questions and answers provided here will guide you to prepare for your upcoming interview and face the questions confidently. In order to add more weightage to your resume, you can take up a Cisco certification or course. Alternatively, you may go through resources on various other Networking and Hardware concepts to grow your knowledge. PREPARING for the Cisco interview questions and answers in this article will definitely help you stand out as a strong potential candidate for the job. Useful Resources:
|
|
| 2. |
Write a program for finding the first and last occurrences (or positions) of a number in an array of a sorted manner. |
|
Answer» Assign firstPos and lastPos values as -1 in the beginning, as we need to find them yet. Within for loop, you need to compare a given element with each element of an ARRAY. When an element is found for the first time, we will update the firstPos value with i. After that, WHENEVER we find an element, we will update the lastPos value with i. Then firstpos and lastPos value will be printed. // C++ PROGRAM#include <bits/stdc++.h>using namespace std;void findFirstAndLastFunc(int a[], int n, int x){ int firstPos = -1, lastPos = -1; for (int i = 0; i < n; i++) { if (x != a[i]) continue; if (firstPos == -1) firstPos = i; lastPos = i; } if (firstPos != -1) COUT << "First Occurrence = " << firstPos<< "\n Last Occurrence = " << lastPos; else cout << "Element not Found";}int main(){ int a[] = { 1, 2, 2, 2, 3, 3, 4, 5, 7, 7}; int n = sizeof(a) / sizeof(int); int x = 7; findFirstAndLastFunc(a, n, x); return 0;}Output: First Occurrence = 8Last Occurrence = 9 |
|
| 3. |
Write a program for finding the greatest difference between two elements of an array that is in increasing order of elements. |
|
Answer» A SOLUTION for this problem can be achieved with the usage of two loops. Initially, we consider the maximum difference value as the difference between the first two array elements. Later, the elements will be picked one by one in the outer loop and the difference between the picked element and every other array element will be calculated in the inner loop, then that difference will be compared with the maximum difference calculated so far. Program: // Java programclass MaxDiffrence{ /* The function will ASSUME that there will be at least two elements in an array. The function will return a negative value if the array is in decreasing order of sorting. This function will return 0 if elements are equal. */ int maximumDiff(int x[], int size) { int res = x[1] - x[0]; int i, j; for (i = 0; i < size; i++) { for (j = i + 1; j < size; j++) { if (x[j] - x[i] > res) res = x[j] - x[i]; } } return res; } // Driver program for testing above function public static void main(String[] args) { MaxDifference md = new MaxDifference(); int array[] = {2, 3, 90, 10, 120}; System.out.println("Maximum difference between two elements of an array is " + md.maximumDiff(array, 5)); }}Output: Maximum difference between two elements of an array is 118 |
|
| 4. |
Write a program for printing all permutations of a given string. |
|
Answer» A permutation means re-arranging the ordered list(L) elements into a correspondence of one-to-one with the L itself. It is also known as an “order” or “arrangement NUMBER”. There will be N! permutation for a string with length n. For finding all permutations of a given string, the recursive algorithm will make use of backtracking which finds the permutation of numbers by swapping a single element per iteration. We are providing the “XYZ” string as an input in the below given example. It will produce 6 permutations for a given string. The permutation for a string “XYZ” are “XYZ”, “YXZ”, “ZYX”, “XZY”, “YZX”, “ZXY”. // C Program to print all permutations of a given string including duplicates#include <stdio.h>#include <string.h>// Function for swapping values at two pointers void swap(char *a, char *b) { char temp; temp = *a; *a = *b; *b = temp;}/* Function for printing permutations of a string. This function takesthree parameters: String, Starting index of the string, LAST index ofthe string. */void permute(char *a, int beg, int end){ int i; if (beg == end) printf("%s\n", a); else { for (i = beg; i <= end; i++) { swap((a+beg), (a+i)); permute(a, beg+1, end); //backtracking method swap((a+beg), (a+i)); } }}// Driver program for testing above defined functions int MAIN(){ char string[] = "XYZ"; int n = strlen(string); permute(string, 0, n-1); return 0;}Output: XYZXZYYXZYZXZYXZXY |
|
| 5. |
Write a program to create a stack using a linked list in Java. |
|
Answer» We can easily implement a stack using the LINKED list. A stack will have a top pointer which is the “head” of the stack where the item will be pushed and popped at the head of the list. The link field of the first node will be null and the link field of the second field will have the address of the first node and so on and the address of the last node will be stored in the “top” pointer. The major advantage of linked list usage over an array is we can implement a stack that can grow or shrink according to the need. As the array is of fixed size, it will lead to stack overflow by putting restrictions on the maximum capacity of an array. In the linked list, each new node will be allocated dynamically, so overflow will not occur. Stack Operations are:
Output: 30->25->20->15->Top element of Stack is 3020->15->Top element of Stack is 20 |
|
| 6. |
What is an auto keyword in C? |
Answer»
Syntax: auto <data_type> <variable_name>; Example: auto int x = 1;Here, x is a variable of storage class “auto” and with DATA type int. |
|
| 7. |
How Multithreading will be achieved in Python? |
Answer»
|
|
| 8. |
What is a void pointer in C? Can a void pointer be dereferenced without being aware of its type? |
|
Answer» A VOID POINTER is a pointer that is useful in POINTING to the memory location having an undefined data type at the time of defining a variable, which means it can be any data of any arbitrary type. You can dereference a void pointer only after explicit casting. For example: INT x = 10;void *y = &x;printf(“%d\n”, *((int*)y));In the above-given CODE, we have declared a normal variable x with the integer data type, and assigned reference of x into a void pointer y. Using printf(), we are displaying the value of y by dereferencing it. |
|
| 9. |
Differentiate between C and C++. |
||||||||||||||||||||||
Answer»
|
|||||||||||||||||||||||
| 10. |
How will swapping lead to better memory management? |
|
Answer» Swapping is a process/memory management TECHNIQUE used by the operating system(os) for increasing the processor utilization by moving a few blocked processes from the MAIN memory into the secondary memory. This will lead to a QUEUE formation that has temporarily suspended processes and the execution will be continued with the processes that are NEWLY arrived. At the regular intervals fixed by the operating system, processes can be moved from the main memory to secondary storage, and then later they can be moved back. Swapping will ALLOW multiple processes to run, that can fit into memory at a single time. Thus, we can say that swapping will lead to better memory management. |
|
| 11. |
What is Virtual memory? |
Answer»
|
|
| 12. |
What is a deadlock in Operating Systems? What are the situations for the deadlock to happen? |
|
Answer» DEADLOCK REFERS to the situation that happens in the operating system where each process will enter into the waiting state for obtaining the resource which has been ASSIGNED to some other process. Consider a real-time example of traffic that is going only in a single direction. Here, we can consider the bridge as a resource. If one car backs up, the deadlock situation will be RESOLVED easily. Multiple cars may have to be backed up on deadlock OCCURRENCE. So it might lead to starvation. The process will be considered to be in a deadlock when the following conditions get satisfied simultaneously:
|
|
| 13. |
What are the different types of memories used in the CISCO router? |
|
Answer» Different types of memories are being used in a CISCO router. They are:
|
|
| 14. |
Explain how Cut-through LAN switching works. |
|
Answer» Cut-through LAN switching is useful in packet-switching systems. In the packet-switching technique, the message will be divided into many SMALLER UNITS known as packets and it will be individually routed from source to the destination. It does not require the establishment of a dedicated circuit for communication, as it is a connection-less network switching technique. In cut−through switching, when a packet or data frame begins arriving at a switch or bridge, the transmission of data can be started immediately after the destination address field has arrived. The switch will do a look–up at the address table stored in it and check for the VALIDITY of the destination address. If it is a valid address and the outgoing link is available, the data frame transmission into the destination port will be immediately started by a switching device, even before the ARRIVAL of the remaining frame. Here, the switching device will act as a forwarder of data frames. The error checks cannot be performed when it STARTS forwarding, as the total frame is still not available. For error handling, it depends upon the destination devices. |
|
| 15. |
What is a transparent firewall? |
|
Answer» A transparent firewall or bridge firewall will behave like a line of the layer among 2 devices and can be easily installed into an existing NETWORK without any modification into the Internet Protocol (IP) address. The transparent firewall will allow for entering into the traffic of layer 3 from the level of HIGHER security to lower security LEVELS without the help of access lists. It will act SIMILAR to a bridge as it inspects and moves network frames between interfaces. A transparent firewall is considered a “stealth firewall” that supports outside as well as inside interfaces. Using this, security equipment can be connected with the same network on external and internal ports, with a separate VLAN(Virtual Local Area Network) for each interface. |
|
| 16. |
What is the CISCO default TCP session timeout? |
|
Answer» The default timeout in the TCP session for CISCO will be ONE minute. Here, connection slots will GET freed on an average of SIXTY seconds later, when the sequence of normal connection close has been COMPLETED. It can be configured into other settings as per the requirements. For the connection and translation slots of different protocols, a global IDLE timeout duration can be set manually. The resources will be returned so that pools can be freed, in case slots are not used for the specified idle time. |
|
| 17. |
How is a TCP connection made? |
|
Answer» A TCP(Transmission Control Protocol) connection will be done as given below:
|
|
| 18. |
What are the Benefits of Subnetting? |
|
Answer» Subnetting refers to the process of dividing a larger network into smaller networks. In the below-given image, the network has been divided into two broadcast networks, which will reduce the network load and will provide greater network security to the users. The benefits of subnetting are:
|
|
| 19. |
What are TACACS (Terminal Access Controller Access Control System) and RADIUS (Remote Authentication Dial In User Service) in networking? |
Answer»
|
|
| 20. |
Give the reasons why a Layered model is used by the Networking industry. |
| Answer» | |
| 21. |
What is an IP access list? |
|
Answer» An IP access list is a rule set for traffic control in the network and for reducing the possibilities of network attacks. This list will be useful in filtering the traffic BASED on rules that are defined for incoming as well as outgoing networks. The standard IP access list features are:
|
|
| 22. |
Explain in detail about Bridges in Networking and mention its usage. |
|
Answer» A BRIDGE is a networking device that will connect numerous LANs (Local Area Networks) for forming a larger LAN. Also, it can connect LAN segments to form newer LAN segments. It operates in the OSI MODEL’s Data-Link layer. Bridges are helpful in increasing the network capacity of a single LAN by joining multiple LANs. Working of Bridge: The bridge will connect two or more different LANs that are having similar protocols and help to communicate between the devices (nodes) in them. It will accept all the data packets and all of them will be amplified to the other side. The bridges are considered to be intelligent devices as they will permit the passing of only selective packets from them. A bridge will pass only those packets which are addressed from the node of one network to the node of the other network. That means the bridge will consult a database on receiving the data frame for DECIDING whether to pass, transmit or discard the frame.
Uses of Bridge:
|
|
| 23. |
Which protocol will be used for booting diskless workstations? |
|
Answer» BootP or BOOTSTRAP Protocol will be used for booting the diskless workstations across the INTERNET by themselves. Similar to DHCP (DYNAMIC Host CONFIGURATION Protocol), BootP will allow a computer to obtain the server’s IP ADDRESS as well as their own IP address. |
|
| 24. |
What is a diskless workstation? |
|
Answer» Diskless workstations refer to the client computers that are in connection with a networked server. These computers will need only a minimum AMOUNT of hardware for interacting with the system by the user. They do not have a hard disk. Data and programs will be retrieved from the NETWORK. The server will do all the “hard work”, including data storage, booting, and performing calculations. Diskless workstations are helpful in reducing the overall LAN cost as a single disk drive with large-capacity will be less expensive than multiple low-capacity drives. Along with this, it also simplifies the security and backups because all files are in a single place, i.e., on the file server. Also, data access from a larger REMOTE file server is usually faster than data access from a smaller local storage device. The major disadvantage of these diskless workstations is that they become useless on network FAILURE. |
|