Stacks can be used to implement algorithms involving Infix, postfix and prefix expressions. So let us learn about them:- INFIX:- An infix expression is a single letter, or an operator, proceeded by one infix string and followed by another infix string. A A + B (A + B) + (C – D) PREFIX:- A prefix expression is a single letter, or an operator, followed by two prefix strings. Every prefix string longer than a single variable contains an operator, first operand and second operand A + A B + + …
nikoo28
nikoo28
a tech-savvy guy and a design buff... I was born with the love for exploring and want to do my best to give back to the community. I also love taking photos with my phone and Canon Kiss X-5 in order to capture moments in my life. It's my pleasure to have you here.
-
-
Stacks can be used to check if the given expression has balanced symbols or not. The algorithm is very much useful in compilers. Each time parser reads one character at a time. If the character is an opening delimiter like ‘(‘ , ‘{‘ or ‘[‘ then it is PUSHED in to the stack. When a closing delimiter is encountered like ‘)’ , ‘}’ or ‘]’ is encountered, the stack is popped. The opening and closing delimiter are then compared. If they match, the parsing of the string continues. If they …
-
An implementation of stack is similar to that of a Linked List. We will try to discuss the basic operations in a stack discussed in this post. MAIN OPERATIONS ON A STACK:- push( int ) :- Inserts a data into the stack pop :- Returns the topmost data from the stack AUXILIARY OPERATIONS ON A STACK int Top( ) :- returns the topmost element on the stack int Size( ) :- returns the total size of the stack int isStackEmpty( ) :- returns true if the stack is empty The …
-
-
From Wikipedia: A segmentation fault occurs when a program attempts to access a memory location that it is not allowed to access, or attempts to access a memory location in a way that is not allowed (for example, attempting to write to a read-only location, or to overwrite part of the operating system). Segmentation is one approach to memory management and protection in the operating system. It has been superseded by paging for most purposes, but much of the terminology of segmentation is still used, “segmentation fault” being an example. …
-
Linked List
Find the merging point of 2 Linked Lists. Popularly called the Y-node problem.
by nikoo2811 minutes readQuestion: You are given the head pointer to 2 single Linked Lists, and both of the lists converge at a certain point and then advance forward. We need to find the address of the node, at which both of the Linked Lists meet. Input: 4 -> 8 -> 15 -> 42 -> 99 16 -> 23 -> Output: 42 Suppose there are two single Linked Lists both of which intersect at some point and become a single Linked list. The head or start pointer of both the lists …
-
This is one of the method, not everyone is aware of in C. To generate a random number, C itself provides us a method srand(). We can use it in this way. NOTE: The function srand(time(NULL)) can only be called once in the program.
-
Many of us must have heard of the clause “Real Programmers code in C” and it is faster than any other language because “it is close to the machine“. What is so special about this language that makes it different from any other language. Let us try to explore this answer to some extent. There isn’t much that’s special about C. That’s one of the reasons why it’s fast. Newer languages which have support for garbage collection, dynamic typing and other facilities which make it easier for the programmer to …
-
Copying an entire Linked List, means allocating new memory and copying all the data to the new location. This requires traversing each node and copying its data to a new location, keeping the original data intact.
-
Question: Write a program to check if the given Linked List is a palindrome or not? Input: 1.> 4, 8, 15, 16, 23, 42 2.> 4, 8, 15, 16, 15, 8, 4 Output: 1.> IS NOT A PALINDROME 2.> IS A PALINDROME What is a Palindrome? According to Wikipedia, A palindrome is a word, phrase, number, or other sequence of symbols or elements, whose meaning may be interpreted the same way in either forward or reverse direction. Thus, numbers like 121, 1331, 98711789 are palindromes. Similarly, Linked Lists can be …