500 most asked apti ques in tcs, wipro, infos(105pgs) PDF

Title 500 most asked apti ques in tcs, wipro, infos(105pgs)
Author Karri Kumar
Course Java Assignment
Institution Central University of Andhra Pradesh
Pages 65
File Size 4.3 MB
File Type PDF
Total Downloads 81
Total Views 135

Summary

orget about spam, advertising mailings, hacking and attacking robots. Keep your real mailbox clean and secure. Temp Mail provides temporary, secure, anonymous, free, disposable email address....


Description

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

www.MyPlacementPrep.com

Pro Material Series

Join Telegram Channel for more updates: https://t.me/MyPlacementprepApp

Visi www.MyPlacementPrep.com . India’s No1 website for Placement Materials and Free mock test Series Free Placement Preparation Online Course video now available.

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions 1. Addition Of Two Matrices In C: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. #include int main() { int m, n, c, d, first[1 0][10], second[10][10], sum[ 10][10]; printf("Enter the number of rows and columns of matrix\n"); scanf( "%d%d", & m, &n); printf("Enter the elements of first matrix\n"); for (c = 0; c < m; c++) for (d = 0; d < n; d++) scanf("%d", &first[c][d]); printf("Enter the elements of second matrix\n"); for (c = 0; c < m; c++) for (d = 0 ; d < n; d++) scanf("%d", &second[ c][d]); printf("Sum of entered matrices:-\n"); for (c = 0; c < m; c++) { for (d = 0 ; d < n; d++) { sum[c][d] = first[c][d] + second[c][d]; printf("%d\t", sum[c][d]); }

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com printf("\n"); } return 0; }

Wipro Elite NLTH Coding / Programming Questions Output: 2. Program to find the average of n (n < 10) numbers using arrays #include int main() { int marks[10], i, n, sum = 0, average; printf("Enter n: "); scanf("%d", &n); for(i=0; idata = x; start->next = NULL; return; } t->data = x; t->next = start; start = t; } void insert_at_end(int x) {

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com struct node *t, *temp; t = (struct node*)malloc(sizeof(struct node)); count++; if (start == NULL) { start = t; start->data = x; start->next = NULL; return; } temp = start; while (temp->next != NULL) temp = temp->next; temp->next = t; t->data = x; t->next = NULL; } void traverse() {

Wipro Elite NLTH Coding / Programming Questions 97. struct node *t; 98. 99. t = start; 100. 101. 102. 103. 104.

if (t == NULL) { printf("Linked list is empty.\n"); return; }

105. 106. printf("There are %d elements in linked list.\n", count) ; 107. 108. 109. 110.

while (t->next != NULL) { printf("%d\n" , t- >data); t = t->next;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com 111. 112. 113.

} printf("%d\n", t->data); }

114. 115. 116. 117.

void delete_from_begin() { struct node *t; int n;

118. 119. 120. 121. 122.

if (start == NULL) { printf("Linked list is already empty.\n"); return; }

123. 124. 125. 126. 127. 128.

n = start->d ata; t = start->next; free(start); start = t; count--;

129. 130. 131.

printf("%d deleted from beginning successfully.\n", n); }

132.

Wipro Elite NLTH Coding / Programming Questions 133. 134.

void delete_from_end() { struct node *t, *u;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com 135.

int n;

136. 137. 138. 139. 140. 141. 142. 144. 145. 146. 147. 148. 149. 150. 151. 152.

if (start == NULL) { printf("Linked list is already empty.\n"); return; }

count--; 143. if

} t = start; 153.

154. 155. 156. 157.

while (t->next != NULL) { u = t; t = t->next; }

158. 159. 160. 161.

n = t->data; u->next = NULL; free(t);

162. 163. 164.

printf("%d deleted from end successfully.\n", n) ; }

4. Operations On Linked List (start->next == NULL) { n = start->data; free(start); start = NULL; printf("%d deleted from end successfully.\n", n); return;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions #include #include struct node { int data; struct node *next; }; void display(struct node* head) { struct node *temp = head; printf("\n\nList elements are - \n"); while(temp != NULL) { printf("%d --->",temp->data); temp = temp->next; } } void insertAtMiddle(struct node *head, int position, int value) { struct node *temp = head; struct node *newNode; newNode = malloc(sizeof(struct node)); newNode->data = value; int i; for(i=2; inext != NULL) { temp = temp->next; } } newNode->next = temp->next; temp->next = newNode; }

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions void insertAtFront(struct node** headRef, int value) { struct node* head = *headRef; struct node *newNode; newNode = malloc(sizeof(struct node)); newNode->data = value; newNode->next = head; head = newNode; *headRef = head; } void insertAtEnd(struct node* head, int value){ struct node *newNode; newNode = malloc(sizeof(struct node)); newNode->data = value; newNode->next = NULL; struct node *temp = head; while(temp->next != NULL){ temp = temp->next; } temp->next = newNode; } void deleteFromFront(struct node** headRef){ struct node* head = *headRef; head = head->next; *headRef = head; } void deleteFromEnd(struct node* head){ struct node* temp = head; while(temp->next->next!=NULL){ temp = temp->next; }

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions temp->next = NULL; } void deleteFromMiddle(struct node* head, int position){ struct node* temp = head; int i; for(i=2; inext != NULL) { temp = temp->next; } } temp->next = temp->next->n ext; } int main() { /* Initialize nodes */ struct node *head; struct node *one = NULL; struct node *two = NULL; struct node *three = NULL; /* Allocate memory */ one = malloc(sizeof(struct node)); two = malloc(sizeof(struct node)); three = malloc(sizeof(struct node)); /* Assign data values */ one->data = 1; two->data = 2; three->data = 3; /* Connect nodes */ one->next = two; two->next = three; three->next = NULL;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions /* Save address of first node in head */ head = one; display(head); // 1 --->2 --->3 ---> insertAtFront(&head, 4); display(head); // 4 --->1 --->2 --->3 ---> deleteFromFront(&head); display(head); // 1 --->2 --->3 ---> insertAtEnd(head, 5); display(head); // 1 --->2 --->3 --->5 ---> deleteFromEnd(head); display(head); // 1 --->2 --->3 ---> int position = 3; insertAtMiddle(head, position, 10); display(head); // 1 --->2 --->10 --->3 ---> deleteFromMiddle(head, position); display(head); // Output: List elements are - 1 --->2 --->3 ---> List elements are - 4 --->1 --->2 --->3 List elements are - 1 --->2 --->3 ---> List elements are 1 --->2 --->3 ---> } --->

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions 1 --->2 --->3 --->5 ---> List elements are - 1 --->2 --->3 ---> List elements are 1 --->2 --->10 --->3 ---> List elements are - 1 --->2 --->3 ---> 5. Circular Linked List #include #include #include #include

struct node { int data; int key; struct node *next; }; struct node *head = NULL; struct node *current = NULL; bool isEmpty() { return head == NULL; } int length() { int length = 0; //if list is empty if(head == NULL) { return 0; } current = head->next;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions while(current != head) { length++; current = current->n ext; } return length; } //insert link at the first location void insertFirst(int key, int data) { //create a link struct node *link = (struct node*) malloc(sizeof(struct node)); link->key = key; link->data = data; if (isEmpty()) { head = link; head->next = head; } else { //point it to old first node link->next = head; //point first to new first node head = link; } } //delete first item struct node * deleteFirst() { //save reference to first link struct node *tempLink = head; if(head->next == head) { head = NULL; return tempLink; } //mark next to first link as first head = head->next; //return the deleted link return tempLink;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

}

Wipro Elite NLTH Coding / Programming Questions //display the list void printList() { struct node *ptr = head; printf("\n[ "); //start from the beginning if(head != NULL) { while(ptr->next != ptr) { printf("(%d,%d) ",ptr- >key,ptr->data); ptr = ptr-> next; } } printf(" ]"); } void main() { insertFirst(1,10); insertFirst(2,20); insertFirst(3,30); insertFirst(4,1); insertFirst(5,40); insertFirst(6,56); printf("Original List: "); //print list printList(); while(!isEmpty()) { struct node *temp = deleteFirst(); printf("\nDeleted value:"); printf( "(%d,%d) ",temp->key,temp->data); } printf("\nList after deleting all items: "); printList(); }

Output:

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions Original List: [ (6,56) (5,40) (4,1) (3,30) (2,20) ] Deleted value:(6,56) Deleted value:(5,40) Deleted value:(4,1) Deleted value:(3,30) Deleted value:(2,20) Deleted value:(1,10) List after deleting all items: []

6. #include #include #include #include

struct node { int data; int key; struct node *next; struct node *prev; }; //this link always point to first Link struct node *head = NULL; //this link always point to last Link struct node *last = NULL; struct node *current = NULL; //is list empty bool isEmpty() { return head == NULL; } int length() { int length = 0; struct node *current; for(current = head; current != NULL; current = current->next) { length++;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions } return length; } //display the list in from first to last void displayForward() { //start from the beginning struct node *ptr = head; //navigate till the end of the list printf("\n[ "); while(ptr != NULL) { printf("(%d,%d) ",ptr->k ey,ptr->data); ptr = ptr->next; } printf(" ]"); } //display the list from last to first void displayBackward() { //start from the last struct node *ptr = last; //navigate till the start of the list printf("\n[ "); while(ptr != NULL) { //print data printf("(%d,%d) ",ptr->k ey,ptr->data); //move to next item ptr = ptr ->prev; } }

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com

Wipro Elite NLTH Coding / Programming Questions //insert link at the first location void insertFirst(int key, int data) { //create a link struct node *link = (struct node*) malloc(sizeof(struct node)); link->key = key; link->data = data; if(isEmpty()) { //make it the last link last = link; } else { //update first prev link head->prev = link; } //point it to old first link link->next = head; //point first to new first link head = link; } //insert link at the last location void insertLast(int key, int data) { //create a link struct node *link = (struct node*) malloc(sizeof(struct node)); link->key = key; link->data = data; if(isEmpty()) { //make it the last link last = link; } else { //make link a new last link last->next = link;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com //mark old last node as prev of new link link->prev = last; } //point last to new last node

Wipro Elite NLTH Coding / Programming Questions last = link; } //delete first item struct node* deleteFirst() { //save reference to first link struct node *tempLink = head; //if only one link if(head->next == NULL){ last = NULL; } else { head->next->prev = NULL; } head = head->next; //return the deleted link return tempLink; } //delete link at the last location struct node* deleteLast() { //save reference to last link struct node * tempLink = last; //if only one link if(head->next == NULL) { head = NULL; } else { last->prev->next = NULL; } last = last->prev;

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com //return the deleted link return tempLink; } //delete a link with given key struct node* delete(int key) {

Wipro Elite NLTH Coding / Programming Questions //start from the first link struct node* current = head; struct node* previous = NULL; //if list is empty if(head == NULL) { return NULL; } //navigate through list while(current->key != key) { //if it is last node if(current->next == NULL) { return NULL; } else { //store reference to current link previous = current; //move to next link current = current->next; } } //found a match, update the link if(current == head) { //change first to point to next link head = head->next; } else { //bypass the current link

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com current->prev->next = current->next; } if(current == last) { //change last to point to prev link last = current->prev; } else { current->next->prev = current->prev; } return current; }

Wipro Elite NLTH Coding / Programming Questions bool insertAfter(int key, int newKey, int data) { //start from the first link struct node *current = head; //if list is empty if(head == NULL) { return false; } //navigate through while(current->key //if it is last if(current->next == NULL) { return false; } else { } } //move to current = next link current->next; list != key) {

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com node //create a link struct node *newLink = (struct node*) malloc(sizeof(struct node)); newLink-> key = newKey; newLink->data = data; if(current == last) { newLink->next = NULL; last = newLink; } else { newLink->next = current->next; current->next->prev = newLink; } newLink->prev = current; current->next = newLink; return true; } void main() { insertFirst(1,10); insertFirst(2,20);

Wipro Elite NLTH Coding / Programming Questions insertFirst(3,30); insertFirst(4,1); insertFirst(5,40); insertFirst(6,56); printf("\nList (First to Last): "); displayForward(); printf("\n"); printf("\nList (Last to first): "); displayBackward(); printf("\nList , after deleting first record: "); deleteFirst(); displayForward(); printf("\nList , after deleting last record: "); deleteLast(); displayForward(); printf("\nList , insert after key(4) : "); insertAfter(4,7, 13); displayForward(); printf("\nList , after delete key(4) : "); delete(4); displayForward();

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com }

Output: List (First to Last): [ (6,56) (5,40) (4,1) (3,30) (2,20) List (Last to first): [ (1,10) (2,20) (3,30) (4,1) (5,40) List , after deleting first record: [ (5,40) (4,1) (3,30) (2,20) (1,10) List , after deleting last record: [ (5,40) (4,1) (3,30) (2,20) ] List , insert after key(4) : [ (5,40) (4,1) (4,13) (3,30) (2,20)

(1,10) ] (6,56) ] ]

]

Wipro Elite NLTH Coding / Programming Questions List , after delete key(4) : [ (5,40) (4,13) (3,30) (2,20) ]

7. Topological Sort Program In C Language #include int main(){ int i,j,k,n,a[10][10],indeg[10],flag[10],count=0; printf("Enter the no of vertices:\n"); scanf("%d",&n); printf("Enter the adjacency matrix:\n"); for(i=0;iedge[2].dest = 2; if (isCycle(graph)) printf( "graph contains cycle" );

Wipro Elite NLTH Coding / Programming Questions else printf( "graph doesn't contain cycle" ); return 0; } Output:

Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com graph contains cycle 16. Computational Geometry #include using namespace std; struct Point { int x, y; };

Wipro Elite NLTH Coding / Programming Questions // To find orientation of ordered triplet (p, q, r). // The function returns following values // 0 --> p, q and r are colinear // 1 --> Clockwise // 2 --> Counterclockwise int orientation(Point p, Point q, Point r) { int val = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y); if (val == 0) return 0; // colinear return (val > 0)? 1: 2; // clock or counterclock wise }

Wipro Elite NLTH Coding / Programming Questions Join Telegram Channel: https://t.me/MyPlacementprepApp Join Telegram Group: https://t.me/myPlacementPrep

Free Placement Preparation Online Course with Free Mock Test visit: www.MyPlacementPrep.com // Prints convex hull of a set of n points. void convexHull(Point points[], int n) { // There must be at least 3 points if (n < 3) return; // Initialize Result vector hull; // Find the leftmost point int l = 0; for (int i = 1; i < n; i++) if (points[i].x < points[l].x) l = i;

Wipro Elite NLTH Coding / Programming Questions // Start from leftmost point, keep moving counterclockwise // until reach the start point again. This loop runs O(h) // times where h is number of points in result or output. int p = l, q; do { // Add current point to result hull.push_back(points[p]); // Search for a point 'q' such that orientation(p, x, // q) is counterclockwise ...


Similar Free PDFs