## Computer Graphics – Lab 19 Line with Stipple Patterns

[wpdm_package id=’1256′] Sample Input – Write a program to draw line with stipple patterns. Sample Output – [sourcecode lang=”cpp”] glEnable(GL_LINE_STIPPLE); glLineStipple(1,0x00ff); glBegin(GL_LINES); glVertex2f(100,100); glVertex2f(600,600); glEnd();…

## Check if two Trees are Structurally Similar

[wpdm_package id=’1352′] Algorithm: Use Recursion. If both the trees are NULL, return true. If only one of the trees is NULL return false. Recursively find…

## How to Delete a Tree

[wpdm_package id=’1354′] Algorithm: [sourcecode lang=”cpp”] void DeleteBinaryTree(tree_node *root) { if(!root) return; DeleteBinaryTree(root->left); DeleteBinaryTree(root->right); free(root); } [/sourcecode]

## Check if two Trees are Mirrors of each other

[wpdm_package id=’1359′] Algorithm: Return true if both the trees are empty. Return false if only one of the tree is empty. Return false if root…

## Find the level with Maximum Sum in a Binary Tree

[wpdm_package id=’1361′] Algorithm: [sourcecode lang=”cpp”] int FindLevelWithMaxSum() { tree_node *temp; int level=0, maxLevel=0; std::queue<tree_node *> Q; int currentSum=0, maxSum=0; if(!root) return 0; Q.push(root); Q.push(NULL); while(!Q.empty())…

## How to Mirror a Binary Tree

[wpdm_package id=’1363′] Algorithm: Use Recursion. Find the left node and corresponding right node each time using recursion. Swap the nodes. [sourcecode lang=”cpp”] void MirrorOfBinaryTree(tree_node *root)…

## Implement 2 Stacks using 1 Array

Question – How do we implement 2 Stacks using 1 Array? One stack routines should not show a exception unless every slot in array is…

## Print the Root-to-Leaf Paths in a Binary Tree

[wpdm_package id=’1365′] Algorithm: Use Recursion. Store the data in each path in an array while you traverse. Traverse the left subtree and the right subtree.…

## Find the Height of a Binary Tree

[wpdm_package id=’1349′] Algorithm: Use recursion. Find the height of the left subtree. Find the height of the right subtree. Check which is maximum. The maximum…

## SAP Labs Coding Interview Question 1

[wpdm_package id=’1421′] Question – Reverse a string Conditions – i. I have to reverse word by word. ii. When I reverse a word the Last…