Find Height of Binary Tree Represented by Parent Array in C++

sudhir sharma
Updated on 22-Jan-2021 13:48:56

207 Views

In this problem, we are given an array arr[] of size n that denotes a tree. Our task is to find height of Binary Tree represented by Parent array. A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties −The value of the key of the left sub-tree is less than the value of its parent (root) node's key.The value of the key of the right subtree is greater than or equal to the value of its parent (root) node's key.Height of a tree is the number of nodes traversed when going from root node ... Read More

Fermat's Little Theorem in C++

sudhir sharma
Updated on 22-Jan-2021 13:45:58

792 Views

Fermat’s little theorem −This theorem states that for any prime number p,           Ap - p is a multiple of p.This statement in modular arithmetic is denoted as,                  ap  ≡ a (mod p)If a is not divisible by p then,  ap - 1 ≡ 1 (mod p)In this problem, we are given two numbers a and p. Our task is to verify fermat’s little theorem on these values.We need to check if ap  ≡ a (mod p) or ap - 1 ≡ 1 (mod p)Holds true for the given values of a and p.Let’s take ... Read More

File Globbing in Linux using C++

sudhir sharma
Updated on 22-Jan-2021 13:45:44

709 Views

p>File globbing also known as Path Name Expansion. It is the method of recognizing wildcard patterns in linux and  then finding the file path expansion based on these patterns.Wildcard Patterns are strings that are used for selection of multiple files based on patterns.The character patterns like “?” , “[ ]” , “*” are used for pattern matching and multiselection of the files.Example of wildcard characters using in file globbing:Asterisk (*) : the * pattern is used when we need to match 0 or more character after the string in the filename.For example: file* will match all files with name file, files, file2, or with anything ... Read More

Fifth Root of a Number in C++

sudhir sharma
Updated on 22-Jan-2021 13:45:29

1K+ Views

In this problem, we are given a number N. Our task is to find the floor value of the fifth root of a number.Fifth Root of a number is the number which when multiplied to itself 5 times returns the number.If N1/5 = a then, a*a*a*a*a = N.Let’s take an example to understand the problem, Input: N = 325Output: 3Explanation:  The fifth root of 325 is 3.179 whose floor value is 3.Solution Approach: A simple solution to the problem is traversing from 1 to n. And finding the number which when multiplied to itself five times gives the number.Here, the exact value cannot be found ... Read More

Fill Array with 1s Using Minimum Iterations in C++

sudhir sharma
Updated on 22-Jan-2021 13:45:26

199 Views

 In this problem, we are given an array arr consisting of n elements that are either 0 or 1. Our task is to fill array with 1’s using minimum iterations of filling neighbors. Let’s take an example to understand the problem, Input: arr[] = {0, 1, 1, 0, 0, 1}Output: 1Solution Approach −To solve the problem, we need to know the fact that if 1 is present in a position it can convert two neighbouring 0’s to 1.If,                arr[i] is 1.Then,           arr[i-1] and arr[i+1] will be converted to 1.Using this, the ... Read More

Fermat's Last Theorem in C++

sudhir sharma
Updated on 22-Jan-2021 13:33:04

232 Views

Fermat’s last theorem in number theory also known as Fermet’s conjecture is a theorem that states that for power n greater than 2. No three values a, b, c satisfy −          an + bn = cni.e.     if n 32 + 42 = 9 + 16 = 25 = 52. 5, 12, 13 => 25 + 49 = 169 = 132.In this problem, we are given three values, L, R, pow denoting range [L, R] and power. Our task is to verify the fermat’s last theorem for the given range and power.Let’s take an example to understand the problem, ... Read More

Federated Database Management System Issues in C++

sudhir sharma
Updated on 22-Jan-2021 13:32:47

341 Views

Database Management System or DBMS in short refers to the technology of storing and retrieving usersí data with utmost efficiency along with appropriate security measures.Federated Database management system is a special type of DBMS in which transparently maps more that one autonomous database into one database which is federated database.The federated database management system is useful while working with multiple applications that uses federation of databases.There are some issues with the federated database management system. They are −Managing the difference in data models,  while working with federated databases multiple applications can have different type of data models and dealing with these ... Read More

Fast Inverse Square Root in C++

sudhir sharma
Updated on 22-Jan-2021 13:32:33

2K+ Views

In this problem, we are given an integers x. Our task is to calculate Fast inverse square root () of a 32-bit floating point number.  The algorithm to find the inverse square root of the number is of great use in programming, such as vector normalization in video games,  in 3D graphics, etc.  Algorithm: Step 1: The algorithm converts the floating point value to integer. Step 2: Operate on the integer value and return approximate value of the inverse square root.Step 3: Convert the integer value back to floating point using the same method used in step 1.Step 4: The approximation is made for improving precision using ... Read More

Extended Operators in Relational Algebra in C++

sudhir sharma
Updated on 22-Jan-2021 13:31:03

920 Views

Relational data model is the primary data model, which is used widely around the world for data storage and processing. This model is simple and it has all the properties and capabilities required to process data with storage efficiency.They are basic operators on Relation Algebra, here we will learn about some extended operators. They are mainly of three types:Intersection Join Divide  Intersection Operation i s a special type of operation in for relations R1 and R2 where the relation in which the tuples with elements present in both relations i.e. in relation R1 and R2. JOIN Conditional Join is a special type of join in which we ... Read More

External Sorting with Example in C++

sudhir sharma
Updated on 22-Jan-2021 13:30:46

3K+ Views

External Sorting is a category of sorting algorithm that is able to sort huge amounts of data. This type of sorting is applied on data set which acquire large memory which cannot be holded in main memory (RAM) and is stored in secondary memory ( hard disk).The idea of sorting used in external sort is quite similar to merge sort. In also possess two phases like in merge sort, In the sort phase,  small memory size data sets are sorted and then in merge phase, these are combined to a single dataset.External Sorting For a huge data set which cannot be processed in ... Read More

Advertisements