Saturday, August 11, 2018

About of Algorithms and Stack Data structure..

DATA STRUCTURE & ALGORITHMS - STACK DATA STRUCTURE & ALGORITHMS



What is a Data Structure Stack?

An Abstract Data Type (ADT) used in the programming languages is known as a Stack. As the name implies it works as a real stack like a deck of cards or pile of plates.
Stack Example
A real-world stack allows operations at one end only. For instance, a card or plate can be placed or removed from the top of the stack only. Even Stack ADT allows the data operations at only on end. Only the top element of a stack can be accessed at any time.
This feature makes it LIFO data structure. LIFO stands for Last-in-first-out. The element placed last is accessed first. In Stack, operation is called PUSH operation and removal operation is called POP operation.

How Data Structure Stack is represented?

The following diagram depicts a stack and its operations −
Stack Representation
Array, structure, pointer and Linked list can implement a Stack. Stack may be of a fixed size or a have an option of dynamic resizing. In this tutorial stacks are implemented using arrays and hence makes it a fixed stack implementation.

What are the basic operations supported by Stack?

The operations supported by stack involve initializing of the stack, de-initializing. Apart from these, the other operations supported by Stack are:
  • push() − Pushing (storing) an element on the stack.
  • pop() − Removing (accessing) an element from the stack.
By checking the status of the tack, the stack is used efficiently for which some of the functions are added to the stacks:
  • peek() − get the top data element of the stack, without removing it.
  • isFull() − check if stack is full.
  • isEmpty() − check if stack is empty.
At all times, a pointer is maintained to the last PUSHed data on the stack. As this pointer always represents the top of the stack, hence named top. The top pointer provides top value of the stack without actually removing it.

What are the procedures to support Stack functions?

Procedures to support stack functions are−

peek()

Algorithm of peek() function −
1
begin procedure peek
2
return stack[top]
3
end procedure
4
5
Implementation of peek() function in C programming language −
Example
1
int peek() {
2
return stack[top];
3
}
4

isfull()

Algorithm of isfull() function −
1
begin procedure isfull
2
if top equals to MAXSIZE
3
return true
4
else
5
return false
6
endif
7
end procedure
8
9
Implementation of isfull() function in C programming language −
Example
1
bool isfull() {
2
if(top == MAXSIZE)
3
return true;
4
else
5
return false;
6
}
7

isempty()

Algorithm of isempty() function −
1
begin procedure isempty
2
if top less than 1
3
return true
4
else
5
return false
6
endif
7
end procedure
8
9
Implementation of isempty() function in C programming language is slightly different. Top is initialized at -1 and the index in array starts from 0. Check if the stock is zero or -1 and determine that the stack is empty. The code for this is:
Example
1
bool isempty() {
2
if(top == -1)
3
return true;
4
else
5
return false;
6
}
7

What are the steps involved in a Stack Push Operation?

The process of putting a new data element onto stack is known as a Push Operation. Push operation involves a series of steps −
  • Step 1 − Checks if the stack is full.
  • Step 2 − If the stack is full, produces an error and exit.
  • Step 3 − If the stack is not full, increments top to point next empty space.
  • Step 4 − Adds data element to the stack location, where top is pointing.
  • Step 5 − Returns success.
Stack Push Operation
If the linked list is used to implement the stack, then in step 3, allocate space dynamically.

Algorithm for PUSH Operation

A simple algorithm for Push operation can be derived as follows −
1
begin procedure push: stack, data
2
if stack is full
3
return null
4
endif
5
top ← top + 1
6
stack[top] ← data
7
end procedure
8
9
Implementation of this algorithm in C, is very easy by the code −
Example
1
void push(int data) {
2
if(!isFull()) {
3
top = top + 1;   
4
stack[top] = data;
5
} else {
6
printf("Could not insert data, Stack is full. \n");
7
}
8
}
9

What are the steps involved in a Stack Pop Operation?

Pop operation is to access the content while removing it from the stack. In an array implementation of pop() operation, top is decremented to a lower position in the stack to point to the next value and the data element is not actually removed.But in linked-list implementation, pop() actually removes data element and deallocates memory space.
The steps in the Pop operation are −
  • Step 1 − Checks if the stack is empty.
  • Step 2 − If the stack is empty, produces an error and exit.
  • Step 3 − If the stack is not empty, accesses the data element at which top is pointing.
  • Step 4 − Decreases the value of top by 1.
  • Step 5 − Returns success.

Stack Pop Operation

Algorithm for Pop Operation

A simple algorithm for Pop operation can be derived as follows −
1
begin procedure pop: stack
2
if stack is empty
3
return null
4
endif
5
data ← stack[top]
6
top ← top - 1
7
return data
8
end procedure
9
10
Implementation of this algorithm in C, is as follows −
Example
1
int pop(int data) {
2
if(!isempty()) {
3
data = stack[top];
4
top = top - 1;   
5
return data;
6
} else {
7
printf("Could not retrieve data, Stack is empty. \n");
8
}
9
}
10

Data Structure & Algorithms in basic Introduction.....

DATA STRUCTURE & ALGORITHMS INTRODUCTION DATA STRUCTURE & ALGORITHMS


Define Data Structures

The process of organizing the data to use in an efficient way is Data Structure. The main foundation terms of data structures are:
  • Interface − Each data structure has an interface. The set of operations supported by the data structure is Interface. The list of supported operations, type of parameters accepted and the return type of the operations are provided by an Interface.
  • Implementation – The internal representation of the data structure is provided by Implementation. The algorithms used in the operations of the data structures are also defined by the Implementation.

What are the characteristics of a Data Structure?

The following are some of the characteristics of Data Structure
  • Correctness – The interface must be implemented correctly by the Data structure implementation.
  • Time Complexity – Data structure running time or operations execution time need to be small.
  • Space Complexity − Memory usage of a data structure operation should be as little as possible.

Why Data Structure is needed?

Applications face few problems as they becoming more complex with rich data. Some of them are:
  • Data Search − Consider an inventory of 1 million(106) items of a store. If the application is to search an item, it has to search an item in 1 million(106) items every time slowing down the search. The search becomes slower as the data grows.
  • Processor speed − Processor speed although being very high, falls limited if the data grows to billion records.
  • Multiple requests – Even the fast server fails sometimes in searching the data as thousands of users can search data simultaneously on a web server.
Data structure rescue by solving these problems. Data structure facilitates in organizing the data in such a way that it ensures that all the items need not be required to be searched and the data required can be searched instantly.

How to compare Data structure execution time?

The cases used to compare the execution time of the data structure are as follows:
  • Worst Case – In this scenario, the data structure operations takes the maximum time. If an operation's worst case time is Æ’(n) then this operation will not take more than Æ’(n) time where Æ’(n) represents function of n.
  • Average Case − This is the scenario which represent the average execution time of an operation of a data structure. If an operation takes Æ’(n) time in execution, then m operations will take mÆ’(n) time.
  • Best Case − This is the scenario representing the least possible execution time of an operation of a data structure. If an operation takes Æ’(n) time in execution, then the actual operation may take time as the random number which would be maximum as Æ’(n).

What is the basic terminology used in Data Structures?

  • Data − Data are values or set of values.
  • Data Item − Data item refers to single unit of values.
  • Group Items − Data items that are divided into sub items are called as Group Items.
  • Elementary Items − Data items that cannot be divided are called as Elementary Items.
  • Attribute and Entity − An entity is that which contains certain attributes or properties, which may be assigned values.
  • Entity Set − Entities of similar attributes form an entity set.
  • Field − Field is a single elementary unit of information representing an attribute of an entity.
  • Record − Record is a collection of field values of a given entity.
  • File − File is a collection of records of the entities in a given entity set.

ALGORITHM (DAA) I nterview Questions $ Answers!!

Algorithm Interview Questions & Answers



Are you preparing for Business Algorithm job interview? Looking for a recruiting solution? Wisdom jobs can improve candidate sourcing, interviewing and tracking of the applicant for an efficient recruiting process. Top companies are hiring for Algorithm jobs for various positions like Research Development Software Engineer, Research Scientist, Assistant Grade III, Software Developer, Data Analyst, Staff Design Engineer, PHD Student, Technical Lead etc. Skills for Algorithm job include proficiency in Data Structures, C, OOA, Java, Design Analysis, OOP, OOAD etc. In our Algorithm job interview questions and answers page designed by our experts, we explore some of the most common interview questions asked during an Algorithm job interview along with some best answers to help you win the best job.


  1. Answer :
    These are the following arguments which are present in pattern matching Algorithms:
    1) Subject,
    2) Pattern
    3) Cursor
    4) MATCH_STR
    5) REPLACE_STR
    6) REPLACE_FLAG
  2. Answer :
    In the algorithmic notation rather than using special marker symbols, generally people use the cursor position plus a substring length to isolate a substring. The name of the function is SUB.
    SUB returns a value the sub string of SUBJECT that is specified by the parameters i and j and an assumed value of j.
  3. Answer :
    Usually when a user wants to estimate time he isolates the specific function and brands it as active operation. The other operations in the algorithm, the assignments, the manipulations of the index and the accessing of a value in the vector, occur no more often than the addition of vector values. These operations are collectively called as “book keeping operations”.
  4. Answer :
    There are four parts in the iterative process they are:
    Initialization: -The decision parameter is used to determine when to exit from the loop.
    Decision: -The decision parameter is used to determine whether to remain in the loop or not.
    Computation: - The required computation is performed in this part.
    Update: - The decision parameter is updated and a transfer to the next iteration results.
  5. Answer :
    Recursion is the name given to the technique of defining a set or a process in terms of itself. There are essentially two types of recursion. The first type concerns recursively defined function and the second type of recursion is the recursive use of a procedure.
  1. Answer :
    A sub algorithm is an independent component of an algorithm and for this reason is defined separately from the main algorithm. The purpose of a sub algorithm is to perform some computation when required, under control of the main algorithm. This computation may be performed on zero or more parameters passed by the calling routine.
  2. Answer :
    The three most important skills which are used extensively while working with generating functions are:
    1)Manipulate summation expressions and their indices.
    2)Solve algebraic equations and manipulate algebraic expressions, including partial function decompositions.
    3)Identify sequences with their generating functions.
  3. Answer :
    The general strategy in a Markov Algorithm is to take as input a string x and, through a number of steps in the algorithm, transform x to an output string y. this transformation process is generally performed in computers for text editing or program compilation.
  4. Answer :
    In the algorithmic notation, a string is expressed as any sequence of characters enclosed in single quote marks.
  5. Answer :
    • Find the no. of elements on the left side.
    • If it is n-1 the root is the median.
    • If it is more than n-1, then it has already been found in the left subtree.
    • Else it should be in the right subtree
  6. Answer :
    It is a method by which a key can be securely shared by two users without any actual exchange.
  7. Answer :
    The goal is completely fill the distance array so that for each vertex v, the value of distance[v] is the weight of the shortest path from start to v.
  8. Answer :
    This is another recursion procedure which is the number of times the procedure is called recursively in the process of enlarging a given argument or arguments. Usually this quantity is not obvious except in the case of extremely simple recursive functions, such as FACTORIAL (N), for which the depth is N.
  9. Answer :
    This algorithm constructs the vectors TITLE, KEYWORD and T_INDEX.
  10. Answer :
    Sorting algorithms can be divided into five categories:
    a) insertion sorts
    b) exchange sorts
    c) selection sorts
    d) merge sorts
    e) distribution sorts
  11. Answer :
    A brute force algorithm is a type of algorithm that proceeds in a simple and obvious way, but requires a huge number of steps to complete. As an example, if you want to find out the factors of a given number N, using this sort of algorithm will require to get one by one all the possible number combinations.
  12. Answer :
    A greedy algorithm is any algorithm that makes the local optimal choice at each stage with the hope of finding the global optimum. A classical problem which can be solved using a greedy strategy is the traveling salesman problem. Another problems that can be solved using greedy algorithms are the graph coloring problem and all the NP-complete problems.
  13. Answer :
    It is an algorithm that considers systematically all possible outcomes for each decision. Examples of backtracking algorithms are the eight queens problem or generating permutations of a given sequence.
  14. Answer :
    Due to the fact that a backtracking algorithm takes all the possible outcomes for a decision, it is similar from this point of view with the brute force algorithm. The difference consists in the fact that sometimes a backtracking algorithm can detect that an exhaustive search is unnecessary and, therefore, it can perform much better.
  15. Answer :
    When a problem is solved using a divide and conquer algorithm, it is subdivided into one or more subproblems which are all similar to the original problem in such a way that each of the subproblems can be solved independently. In the end, the solutions to the subproblems are combined in order to obtain the solution to the original problem.
  16. Answer :
    An algorithm that sorts by insertion takes the initial, unsorted sequence and computes a series of sorted sequences using the following rules:
    a) the first sequence in the series is the empty sequence
    b) given a sequence S(i) in the series, for 0<=i
  17. Answer :
    Insertion sort provides several advantages:
    a) simple implementation
    b) efficient for small data sets
    c) adaptive - efficient for data sets that are already substantially sorted: the time complexity is O(n + d), where d is the number of inversions
    d) more efficient in practice than most other simple quadratic, i.e. O(n2) algorithms such as selection sort or bubble sort; the best case (nearly sorted input) is O(n)
    e) stable - does not change the relative order of elements with equal keys
    f) in-place - only requires a constant amount O( 1) of additional memory space
    g) online - can sort a list as it receives it
  18. Answer :
    In quicksort, the steps performed are the following:
    a) pick an element, called a pivot, from the list
    b) reorder the list so that all elements with values less than the pivot come before the pivot, while all elements with values greater than the pivot come after it (equal values can go either way)
    c) recursively sort the sub-list of lesser elements and the sub-list of greater elements.
  19. Answer :
    In insertion sorting elements are added to the sorted sequence in an arbitrary order. In selection sorting, the elements are added to the sorted sequence in order so they are always added at one end.
  20. Answer :
    Merging is the sorting algorithm which combines two or more sorted sequences into a single sorted sequence. It is a divide and conquer algorithm, an O(n log n) comparison-based sorting algorithm. Most implementations produce a stable sort, meaning that the implementation preserves the input order of equal elements in the sorted output.
  21. Answer :
    Sorting by merging is a recursive, divide-and-conquer strategy. The basic steps to perform are the following:
    a) divide the sequence into two sequences of length
    b) recursively sort each of the two subsequences
    c) merge the sorted subsequences to obtain the final result
  22. Answer :
    Binary search algorithm always chooses the middle of the remaining search space, discarding one half or the other, again depending on the comparison between the key value found at the estimated position and the key value sought. The remaining search space is reduced to the part before or after the estimated position.
  23. Answer :
    Linear search is a method for finding a particular value in a list which consists of checking every one of its elements, one at a time and in sequence, until the desired one is found. It is the simplest search algorithm, a special case of brute-force search. Its worst case cost is proportional to the number of elements in the list; and so is its expected cost, if all list elements are equally likely to be searched for. Therefore, if the list has more than a few elements, other methods (such as binary search or hashing) may be much more efficient.
  24. Answer :
    It is a search algorithm that considers the estimated best partial solution next. This is typically implemented with priority queues.
  25. Answer :
    In computer science and information theory, Huffman coding is an entropy encoding algorithm used for lossless data compression. The term refers to the use of a variable-length code table for encoding a source symbol (such as a character in a file) where the variable-length code table has been derived in a particular way based on the estimated probability of occurrence for each possible value of the source symbol.

Wednesday, August 1, 2018

Top 10 Most Imp's Programming Language in 2018...

Top 10 Best Programming Languages to Learn for 2018




Top 10 Best Programming Languages to Learn for 2018
There are hundreds of Programming languages exists. It is important to know proper knowledge of languages. Some of the languages are new but a majority are still old. From the last few years, We have seen that there are many changes in the programming field. New languages are taking place of the Old languages. For example, C++ language came after the year 2000. It was much popular even all the projects in the market are based on C++ language. C++ is still used in many projects but the point is demand.  Later on, Today, We will discuss in detail about the Top 10 Best Programming Languages to Learn for 2018. If we talk about Salaries then java developer salary are different than C++.
Best Programming languages are based on the demand in the Market. It depends on, What the market’s Projects want? What do the users want?

Why are Programming Languages so Important?

There are many reasons to learn programming languages. Here are the few reasons about learning Programming Languages are so important:
  • Use the Computers as you Like.
  • To Improve or to rapidly increase the Technology.
  • Trained the machines according to you.
  • Tell Computers What to Do.
  • Skilled Programmers are great in Demand.
  • Boost your Sk ill in Coding.
  • Complete your daily tasks using Robotics.
  • Programming Languages have demanded great in future.

We have listed the Top 10 Best Programming Languages to Learn for 2018. It includes both new and old languages to learn depending on different Criteria:
  1. Python
  2. C#
  3. Java
  4. R
  5. Swift
  6. C++
  7. Arduino
  8. PHP
  9. Ruby
  10. Go
Each year Top 10 Best Programming Languages to Learn for 2018 are ranked on different criteria. These best programming languages for 2018, Let’s discuss each programming language for 2018 in detail. Before move on, Let’s see How do we know about the trend in Programming Language?

How to know about trends in Programming Language?

This is a question in the mind of many skilled programmers. Also, it is difficult for the Computer Science Students who are learning in Programming Languages that whats the trend? So, we are going to tell you the secret for all Top 10 Best Programming Languages to Learn for 2018. For example, you are professor or student, you don’t know what is going in the market? So here are the few suggestions to know about a trend in Computer or programming languages:
  • Github is the platform where you can learn more about latest projects in different programming languages. Furthermore, We recommend to connect with this platform and see what kind of projects are doing there?
  • Join different Communities on google plus or other networks and remain in touch with them. Also, Discussion there with other people about the best programming language.
  • Fiverr is an international platform, where daily thousands of projects on Python, C++, Java, C#, D, R, Ruby and other Programming languages. Moreover, We recommend to stay in touch with this platform and check what type of orders are going there?
  • Other Platforms that you have to be in touch are Upwork or Freelancers.
See More: What’s New Features in Android 8.0 Oreo

1- Python (A new Programming Language)

Python is basically used for testing different types of Microchip. It appeared in the 1980s. Now Python is used by thousand of people because it is easy to understand and just a general purpose and interpreted language. Python is easy to code than Java and C++. Its code can write in fewer lines rather than Java.
We also recommend starting your coding skills using Python because it is easy to read and you can learn a lot of object oriented concepts. It’s a fun language to run because of Highly simple Concepts and Statements.

2- C# is one of the Best Programming Language

We can make different Web based applications or web related projects in C#. For example, different Desktop applications are a major focus on C# programming language.
New Features in C# language:
  • Static classes
  • Partial methods
  • Delegate inference
  • Lambda expression
  • Implicitly typed local variables
  • Query expressions
  • Expression trees
  • Partial methods
It is one of the languages you can use to create applications that will run in the .NET CLR.  It is an evolution of the C and C++ languages and has been created by Microsoft specifically to work with the .NET platform.  The C# language has been designed to incorporate many of the best features from other languages while clearing up their problems.
Top 10 Best Programming Languages to Learn for 2018
Design Goals of C# The Big Ideas
  • The first “Component Oriented” language in the C/C++ family
  • Event driven programming
  • Everything really is an object
  • Next generation robust and durable software
Component concepts are first class 
  • Properties, methods, events
  • Design-time and
  • Integrated documentation using XML
Enables one-stop programming
  • No external files like header files, IDL, etc.
  • Can be embedded in ASP pages

3- Java (Different Projects are now java based)

Java has first appeared on 23 May 1995. Java is widely used language in all over the World. It’s major focus on server-side applications, different games, and reliable sensitive applications. The objective of Java is to make all executions of Java good. Projects written in Java have a dishonor because of many reasons like it is slower and consumes more memory/space than other languages like C++. Moreover, Java is not cased touchy language.
Top 10 Best Programming Languages to Learn for 2018
Major Principles of Java
There were five essential objectives in the making of the Java language:
  • It must be “straightforward, protest arranged, and natural”.
  • Java language must be “more secure and hearty”.
  • It must be “engineering impartial and compact”.
  • Java Programs must execute with “elite”.
  • Coding in Java must be “translated, strong, and dynamic”.

4- R (Best Computing and graphics Language)

R is basically open source Programming language and used for Statistical Computing. Although, the source code for R is written in C and Fortran. Furthermore, there are many front ends available in graphics for R. R has command line interface as well.
We all know that libraries are important to complete the task in a short time. Similarly, R has multiple libraries used for graphics and based on Statistical Computing. Also, it is easy to do make different algorithms in R because it contains more libraries and depends on Statistics graphs.
Important Feature of R Programming Language With Example
As we mentioned above R is interpreted language, so When we enter 3+3 at R Command Prompt and Press Enter. it replies with correct answer 6. As follow below:
> 3+3
6

5- Swift

Swift is included in one of these Top 10 Best Programming Languages to Learn for 2018. Swift is a universally useful programming language constructed utilizing. Furthermore, In a present day, its way to deal with different security system, execution, and programming configuration designs.
The objective of the Swift task is to make the best accessible language.
On the other hand, Swift is expected as a trade for C-based language. Moreover, it incorporates highlights that make the code simpler to peruse and compose. Moreover, Swift and pithy cycle over a range or gathering
Feature of Swift Programming language
  • Structs that help strategies, augmentations, and conventions.
  • Useful programming designs, e.g., guide and channel.
  • Intense blunder dealing with worked in.
Top 10 Best Programming Languages to Learn for 2018

6- C++(Famous Programming language)

C++ is a general purpose Language in the list of Top 10 Best Programming Languages to Learn for 2018.
The C++ language has two principal parts:
  • an immediate mapping of equipment highlights. Also, gave principally by the C subset
  • Zero-overhead reflections based on those mappings.
C++ basically depends on the syntax of C language. But C++ has more libraries as compared to C language. There are many similarities between C and C++. For example, both C and C++ maintain Memory Management of four types.
  1. Static storage.
  2. Thread storage.
  3. Automatic storage.
  4. Dynamic storage.

7- Arduino (Best Programming language for Networking Devices)

Arduino is a language based on C and C++ functions. There are many libraries of Arduino which are written in C/C++ language. Arduino is an open source Programming language in 2018. It’s basically concerned with hardware implementations. Moreover, Arduino boards are available and you have to do some networking side implementations with Coding in C/C++. Also, learn more about Arduino Here.
Therefore Arduino is one of the Top 10 Best Programming Languages to Learn for 2018.

8- PHP (Best language for handling Databases)

PHP is a general language for web development and server side Applications. PHP is widely used in 2017 and 2018. Almost, all the Work on web development is based on HTML, PHP. If we talk about how much secure is this language, then we have to say that database of PHP is much stronger than any other Programming language.
In Short, If you want to do projects in Web development, for example, medical stores projects then we recommend choosing PHP. It is best ever because it handles the server side in a reliable way than another language. Remember, PHP development was started in 1995.

9- Ruby(Dynamic Programming Language in 2018)

The first word comes in mind, when we hear the word Ruby is “Dynamic”. Ruby is a mixture of Dynamic, object oriented and reflective programming language. Also, Ruby is a 22 years Old Programming Language. It was first shown in 1995. But now it is widely used in 2018. Ruby supports multiple programming paradigms. It includes functional and object-oriented Paradigms.
Different Versions are released of Ruby. Ruby 1.9, 2.0, 2.1 and more. Recently, Ruby 2.1.0 was released in 2013.

Top 10 Best Programming Languages to Learn for 2018

10- Go (New Viral Computer Language of 2018)

Go is also a open source Programming language which is freely available. Go is a latest language appeared in 2009.
Feature of Go Language:
  • It is statically typed.
  • We can also scalable this language to large systems.
  • Go is easily readable, without a lot of keywords and repeating.
  • The main feature is, it does not require IDE(Integrated Development Environments).
  • Moreover, it supports networking and multiprocessing.

At last, Which Programming language is best to start learning?

Generally, We recommend to start learning programming from Java or C++. There are many reasons for example, you can learn more concepts of Programming of Object oriented in Java and C++. Furthermore, If you want to build strong background in programming language then choose Java or C++ among these Top 10 Best Programming Languages to Learn for 2018.
Which Programming language are you missing in this list of Top 10 Best Programming Languages to Learn for 2018? What do you think, which Programming language is more strong to start career? Let us know in the Comments.