The document describes code for inserting a node into a binary search tree (BST). It defines a node structure with key and left/right child pointers (lines 4-6). A function newNode creates and returns a new node (lines 9-13). Inorder traversal prints the keys in ascending order (lines 16-23). The insert function checks if the tree is empty and returns a new node, otherwise it recursively inserts the key in the left or right subtree based on key comparison (lines 28-39). Main creates a BST with sample insertions and returns 0 (lines 45-53).
Strategies for Landing an Oracle DBA Job as a Fresher
IIT Hyd exam preps.docx
1. …Insert In a Binary Search Tree…
1. #include <stdio.h>
2. #include <stdlib.h>
3.
4. struct node {
5. int key;
6. struct node *left, *right; };
7.
8. // A utility function to create a new BST node
9. struct node* newNode(int item)
10. { struct node* temp = (struct node*)malloc(sizeof(struct
node));
11. temp->key = item;
12. temp->left = temp->right = NULL;
13. return temp;
14. }
15.
16. // A utility function to do inorder traversal of BST
17. void inorder(struct node* root)
18. {
19. if (root != NULL)
20. { inorder(root->left);
21. printf("%d ", root->key);
22. inorder(root->right);
23. }
24. }
25.
26. // A utility function to insert
27. // a new node with given key in BST
28. struct node* insert(struct node* node, int key)
29. {
30. // If the tree is empty, return a new node
31. if (node == NULL)
32. return newNode(key);
33.
34. // Otherwise, recur down the tree
35. if (key < node->key)
36. node->left = insert(node->left, key);
37. else if (key > node->key)
38. node->right = insert(node->right, key);
39.
40. // Return the (unchanged) node pointer
41. return node;
42. }
43.
44. // Driver Code
45. int main()
46. {
47. struct node* root = NULL;
48. root = insert(root, 50);
49. insert(root, 30); insert(root, 20);
50. insert(root, 40); insert(root, 70);
51. insert(root, 60); insert(root, 80);
52.
53. return 0;
54. }
2. TC to find rank of matrix: O(row*col) = Row Red Echelon Form + CREF + no of non-zero in diagonal ( i.e
(row*col)+(row*col)+(row*col) )
The rank–nullity theorem is a theorem in linear algebra, which asserts. of a matrix M that
its rank + its col nullity = the number of columns.
Bayes' Theorem states that the conditional probability of an event,
based on the occurrence of another event, is equal to the likelihood
of the second event given the first event multiplied by the probability
of the first event.
k-means clustering is a method of vector quantization, originally from signal processing, that aims to
partition n observations into k clusters in which each observation belongs to the cluster with the nearest
mean (cluster centers or cluster centroid), serving as a prototype of the cluster. This results in a
partitioning of the data space into Voronoi cells. k-means clustering minimizes within-cluster variances
When the number of clusters, K is increased, the distance from centroid to data points will be decreased
and will reach a point where K is the same as the number of data points. This is the reason we have been
using the mean of the distance to the centroids.
Temporal Locality means that a instruction which is recently executed have high chances of execution
again. So the instruction is kept in cache.
Spatial locality (also termed data locality) refers to the use of data elements within relatively close storage
locations. Think of codes using special & temporal
Dynamic Host Configuration Protocol (DHCP) is a network protocol that is used to configure network
devices to communicate on an IP network. A DHCP client uses the DHCP protocol to acquire configuration
information, such as an IP address, a default route, and one or more DNS server addresses from a DHCP
server.