Practice Questions

26

Nov
Bezier Curves:- Bezier curve is a spline approximation curve that can be fitted to any number of control points. The number of control points defines the degree of the Bezier Polynomial. Suppose we have n + 1 control points ,so the degree of the Bezier Polynomial will be ‘n’. Properties of the Bezier ...

23

Nov
Analysis of Algorithms :- In Computer Science, Multiple Algorithms are available to solve a single problem. For example, to sort an array, we have different Algorithms available like Insertion sort, Selection sort, Bubble sort, Quick sort, Merge sort. All these algorithms have different time and space complexities which decides how efficient ...

22

Nov
So Far, we have discussed   Singly Linked list  , Doubly Linked list we will discuss about the circular Linked list which do not have NULL field at the tail node. Why there is need of Circular Linked list ? In both singly and doubly Linked list , the ...

21

Nov
(1) Until 1.4 version we can’t declare a method with variable number of argument if there is a change in number of argument compulsory we should go for new method, it increases length of the code and reduces readability to overcome this problem sun people introduce var-arg methods in 1.5 ...

21

Nov
About Company Accenture is a global business and management consulting firm that provides services , strategy and technology services . It is an service based company that as its headquarters in Dublin, Republic of Ireland. It is the third-largest Employer in the United States with ...

20

Nov
  TCS Recruitment 2018 TCS (Tata Consultancy Services ) is one of the largest IT Service, Consulting company with its headquarters located in Mumbai, Maharashtra. It operates in the 46 countries worldwide and is part of the ...

19

Nov
Variables are divided into 2 divisions in java based on values and position declaration or behavior.   Division – 1 Based on type of value represented by a variable all variables are divided into 2 types : (1) Primitive variables : can be used to represent primitive values. Example : int x = 10 ; (2) Reference ...

18

Nov
(1) Sometimes to meet temporary requirement of the programmer we can declare variables inside a method, block or constructor such type of variables is called local variables or temporary variables or stack variables or automatic variables.   (2) Local variable will be stored inside stack memory.   (3) Local variable will be created while ...

18

Nov
(1) If the value of a variable is not varied from object to object then it is not recommended to declare variable as instance variable, we have to declare such type of variables as class level by using static modifier this is called as static variables in ...

18

Nov
Keypoints to solve Cohen Sutherland questions The two equations should be used to find the intersection points:- For left or right intersection points, equation is Y = m( Xmin  –  x1­)  +  y1            //for left          If we have to find intersection point in right ,then we will use Xmax ,...

17

Nov
Line Clipping Algorithm:- If one point of a line is outside the given window and one point is inside the window , then we will clip the line inside the window. In other words , we will find the intersection of the line with the corresponding boundaries of the window such ...

17

Nov
(1) If the value of variable is varied from object to object such type of variable are called instance variable. For example if we will create a student class the every student have different name or roll number hence every instance of student class must have separate copy of name and ...

17

Nov
In this two dimensional geometric transformations , we will be learning some of the topics:- Point clipping Line clipping Line Clipping Algorithms Polygon Clipping Some Important terminologies :- 1:- Window :- It is the place which is used for display. A display consists of a viewport. A window can ...

13

Nov
Sometimes we can declare an array without name such type of nameless arrays are called anonymous arrays. The main purpose of anonymous arrays is just for instant use (one time usage). We can create anonymous array as follows new int{ 10,20,30,40 };. While creating anonymous arrays we can’t specify ...

12

Nov
Memory Efficient Doubly Linked list :- In doubly Linked list , each node store the address of its successor and predecessor. It is also called a two linked-list . We can navigate in both the directions in doubly linked list. This make use of pointers and takes extra  O(n) ...

12

Nov
In a doubly linked list , each node stores the address of it predecessor and successor except the first and last node. It is also called a two linked-list . We can navigate in both the directions in doubly linked list. We can delete and insert the element if we don’t have ...

11

Nov
An array is an indexed collection of fixed number of homogeneous data elements. The main advantage of array is we can represent huge number of values by using single variable so, that readability of the code will be improved. But the main disadvantage of array is fixed in size i.e. once ...

11

Nov
Detecting a loop or cycle  in linked list is a very common questions asked in the interview.Generally , several methods/approaches  are questioned about solving this question. This question involves a major algorithm which is very useful in detecting cycles like in graphs and linked list. . A cycle in graph makes it ...

11

Nov
A constant value which can be assigned to the variable is named as a literal. Integral  literals For integral data type (byte, short, int, long) we can specify literal value in the following ways : Decimal form (base 10) : Allowed digits are 0 ...

10

Nov
In Java, variables and expressions are of  some type. Each and every data type is clearly defined, every assignment should be checked by compiler for type compatibility. Because of above reasons we can conclude that  Java  is strongly typed programming language. Java is not considered as pure object-oriented programming language because several ...

09

Nov
A linked list is a dynamic data structure where space requirements need not be predetermined. A stack implemented as a linked list also inherits all these properties. The creation of a stack( as a linked list) is the same as the creation of a linked list i.e., after getting node ...

09

Nov
  Array class contains various methods for manipulating array :- Sort the array Fill an array with a value Searching in arrays   The package which is imported in java for the array operations are java.util.arrays. This class is present in the Java Collections Framework. All the methods in the Array class throws a ...

08

Nov
Prequesite:- Singly Linked list  Problem :- You are given with an linked list. Write a program to print the odd nodes containing the odd elements followed by the even nodes with even elements. The result should contain a single linked list. The time complexity should be  O(n) where 'n' is ...

07

Nov
Insertion in Singly Linked List A singly linked list in Data Structures consists of a node and a next pointer. Singly linked list can implemented in Java , C++ and C. A node can be inserted in the linked list in three ways:- 1: Inserting node at the beginning ...

05

Nov
In Midpoint Circle Algorithm , for a given radius 'r' and  screen center position (xc , yc) , we calculate around a circle path centered at origin (0,0). Then each position calculated is moved to its proper position by adding x to xc and y to yc . Equation for Midpoint Circle Algorithm To ...

03

Nov
Identifiers : A name in java program is called identifier which can be used for identification purpose, it can be method name, variable name, class name or label name. 5 identifiers in this example are Test, main, String, args, x   Rules for defining java identifiers ...

30

Oct
After learning how to draw line using certain algorithms , we will proceed to the Circle Drawing algorithms , as it is a frequently used component in the pictures and graphs. Full circle or circular arcs is used in most graphic packages. Let us first understand the properties ...

27

Oct
Queue is a linear data structure with two open ends, called the ‘rear’ and the ‘front’.  Elements are added at the ‘rear’ end and deleted from the ‘front’ end. Element in a queue typically follows  “First In First Out” (FIFO) order, that is element inserted first will be always deleted first. ...

27

Oct
A Color CRT Monitor display images by using a combination of phosphor that emits different light. A combination of RED, GREEN AND WHITE Phosphors is used to emit different color of light. The two basic technique for producing colors in CRT monitors Beam Penetration method Shadow mask method   Beam Penetration Method  ...

27

Oct
The main difference between Random Scan and Raster scan is that Random Scan produces a high resolution images because it stores pictures as a set of line commands rather than storing as a intensity value. Random scan System :- In Random scan system , the electron beam in ...

27

Oct
Generally, the output device in a graphics system is a video-monitor which is based on the Cathode-Ray Tube(CRT). Let us first see, the working of the CRT. Cathode Ray Tube(CRT) :-  It is an special vacuum tube which is used for producing images. When the electron beam  are focused on the phosphor-coated ...

26

Oct
Computer Graphics:- Computer Graphics is an technology that deals with the creation of pictures and images in computer. Generally, it refers to the computer generated images with the graphic software and hardware. Computer Graphics enables us to draw images for both 2-D as well as 3-D. Some areas where Computer ...

03

Oct
If we take an array of length N which contains N positive elements than bitonic subarray is a subarray having n positive integers where n<=N in such a way that all the integers follow one of the sequences: All the integers of subarray are in increasing order. All the integers of ...

03

Oct
Linked list is a linear data structure which is used for storing collections of data. Linked list has the following properties:- 1: The successive elements in the linked list is connected by the pointers. 2: The last element of the linked list point to null. 3: The size of the linked list can ...

02

Oct
Trie Declaration:-Trie is a tree-based data structure, which can be used for efficient Retrieval of a key in a huge set of strings. Structure of the trie node has character data, EndofWord which is Boolean , and pool of child nodes. Each child nodes has pointer equal to English ...

02

Oct
Data structure for Strings:- If we have a set of Strings (all words in a dictionary) , and we want to search for a particular word in that set , so to perform searching faster, we need a efficient way to store set of strings. There are 3 Data Structures to store ...

30

Sep
To convert decimal number to its equivalent binary number we divide the decimal number with the base of binary number which is 2 and then print the remainder in reverse order. We use stack to store the remainders and then pop the stack to print the equivalent binary number. For example :- Decimal ...

30

Sep
The basic idea of bubble sort is to compare two adjoining values and exchange them if they are not in proper order. Given an array of length N then iterate over N-1 times because if we sorted N-1 elements then the last elements are automatically getting its appropriate position. In every ...

29

Sep
Stack is linear abstract data structure. We can done Addition or deletion of elements only at the one open end called the top of the stack. The elements follow “Last In First Out”, typically called LIFO.  Inserting  elements into the stack  is called Push operation. And  deleting elements from the ...

25

Sep
Problem: Given an list of array. Find the elements which is occurring one time. Input:- { 3, 4, 7, 8, 4, 3, 1, 2, 1, 2} Output:- 7 8 Time complexity:- O(n) Space complexity:- O(1).   Solution:-   As we know the XOR of same element gives 0 , unless it gives 1. X ^ 1=X            X ^ X=0   So, ...

24

Sep
Classes A class is an implementation of a type. It  is the only way to implement user defined data type(UDT). A class contain data members/attributes. A class has operations/member function/methods. A class define a namespace. Thus, classes offer data abstraction / encapsulation of object-oriented programming. Classes are similar to structure ...

23

Sep
Problem Statement: Write an efficient algorithm for matching the pattern given by the user in a string. If the pattern exists print the starting indexes in the string else return 1.   Method 1- Brute Force Approach Lets us look what is problem with the Brute-Force Approach for the string matching Let the length ...

22

Sep
Problem Statement : Find the maximum sum subarray in a contiguous array in an efficient way.   Method 1:  Brute force approach Explanation: Simple idea to do so is first generate all the subarrays and compare the sum of all the subarrays and find out ...

22

Sep
  Dynamic Memory Management in C++ is done through two operators :  (1) new  and (2)  delete Dynamic memory is allocated on heap where as memory for non static and local variables is allocated on stack. Memory allocated for local variables in automatically allocated and deallocated by the compiler. Ex- ...

21

Sep
BITMASKING CONCEPTS Any number can be represented in the form of 0’s and 1’s. Number is represented in the power of 2. Q:- Why we need bitmasking ? Ans:- Arthimetic operations on decimal number takes a lot of time internally for calculation. If we calculate it in terms of 0's and 1's, it will ...

20

Sep
An inline function is just another functions. The function prototype is preceded by the keyword inline. An inline function is expanded (inline) at the site of its call (i.e. compile function body and function call together) and the overhead of passing parameters between caller and called functions is avoided. Macros ...

19

Sep
Notion of const-ness 1. The value of const variable cannot be changed after definition. 2. Naturally, a const variable must be initialized when defined.     Compare between #define and const   Advantages of const Naturally constants like ,e,(Golden Ratio) etc. can be compactly defined and used like const int True =1; const int False=0; const NULL=0; Note : ...

19

Sep
The simple DDA has the disadvantage of using the two operations that are expensive in computational time: 1: Floating point addition 2: Round function The Bresenham's Line Drawing Algorithm is another incremental scan conversion algorithm. The big advantage of this algorithm is that it uses ...

19

Sep
  The DDA Line Drawing Algorithm is a Scan-Conversion Algorithm which is based on calculating either the value of ∆x and ∆y. Equation for DDA Line Algorithm We sample the line at unit intervals in one coordinate and calculate the value of other. Suppose , we increment x by 1 unit and successively calculate ...

18

Sep
Sliding Window Maximum Algorithm (To track the maximum of each subarray of size k) Problem:- Write an algorithm to track the maximum of each subarray of size k in time complexity O(n) and space complexity O(k),  where n is the size of the array and k is size of the window ...

18

Sep
Problem Statement : To find the maximum sum of circular subarray  in contiguous circular array. Prerequisite : Kadane’s Algorithm   Examples : Input :   10  -3  -4  7  6  5  -4  -1 Output :  23  (7+6+5-4-1+10) Input :  10  -3  -4  5  -4  -2  7  6  5  -4 Output :  24 (10+7+6+5-4)   In this problem, there can ...

17

Sep
Binary Search for  Infinite Array Problem:-  Given an array of integer write an algorithm to find the element  entered by the user for searching. Take input from the user and return the index of the element (Array size in unknown).    input: arr[] ...

17

Sep
Problem:  Given an array of integer write an algorithm to find the element  which is to be searched. Take input from the user and return the index of the element. int [] arrA = {1,3,5,0,6,9,4,1,2}; Enter the element to be searched :- 5 Output: Element found at index: 3 Naïve approach:- This approach searches the element ...

16

Sep
Problem:. Write an algorithm to count all the possible sub arrays where product of all the elements in the sub array is less than k. You are given with an interger array and a value 'k'.   Example: Int [] nums = {5, 3, 2, 4}; K = 100 Output: 11 Sub arrays: [5], [5 3], ...

12

Sep
In this post , we will learn how to find the majority element in the array. There are number of ways with which  we can find the majority element in an array. A majority element is a element which appears more than n/2 times in the array. Solution 1: The first solution is to ...

Contact us





Scroll Up