Take BTech Tuition from the Best Tutors
Search in
Lesson Posted on 24/02/2018 Learn BTech Information Science Engineering
Infix Expression To Post-fix Expression Conversion Procedure
SR-IT Academy
SR - IT Academy is one of the leading tutorial point providing services like tutoring and computer training...
Algorithm
1. Scan the infix expression from left to right.
2. If the scanned character is an operand, output it.
3. Else,
a. If the precedence of the scanned operator is greater than the precedence of the operator in the stack (or the stack is empty), push it.
b. Else, Pop the operator from the stack until the precedence of the scanned operator is less-equal to the precedence of the operator residing on the top of the stack. Push the scanned operator to the stack.
4. If the scanned character is an ‘(‘, push it to the stack.
5. If the scanned character is an ‘)’, pop and output from the stack until an ‘(‘is encountered.
6. Repeat steps 2-6 until infix expression is scanned.
7. Pop and output from the stack until it is not empty.
read lessLesson Posted on 03/01/2018 Learn BTech Information Science Engineering
Debraj Paul
I had completed MSc in Maths I am an experienced, qualified icse board school teacher with over 12+...
Lesson Posted on 05/07/2017 Learn BTech Information Science Engineering
Shiladitya Munshi
Well, I love spending time with students and to transfer whatever computing knowledge I have acquired...
Take BTech Tuition from the Best Tutors
Lesson Posted on 05/07/2017 Learn BTech Information Science Engineering
What Is The Difference Between Scope And Lifetime?
Shiladitya Munshi
Well, I love spending time with students and to transfer whatever computing knowledge I have acquired...
Lesson Posted on 05/07/2017 Learn BTech Information Science Engineering
Introductory Discussions On Complexity Analysis
Shiladitya Munshi
Well, I love spending time with students and to transfer whatever computing knowledge I have acquired...
What is Complexity Analysis of Algorithm?
Complexity Analysis, simply put, is a technique through which you can judge about how good one particular algorithm is. Now the term “good” can mean many things at different times.
Suppose you have to go from your home to the Esplanade! There are many ways from your home that may lead to Esplanade. Take any one, and ask whether this route is good or bad. It may so happen that this route is good if the time of travel is concerned (that is the route is short enough), but at the same time, it may be considered bad taking the comfort into considerations (This route may have many speed breakers leading to discomforts). So, the goodness (or badness as well) of any solution depends on the situations and whatever is good to you right now, may seem as bad if the situation changes. In a nutshell, the goodness/badness or the efficiency of a particular solution depends on some criteria of measurements.
So what are the criteria while analyzing complexities of algorithms?
Focusing only on algorithms, the criteria are Time and Space. The criteria Time, judges how fast or slow the algorithms run when executed; and the criteria Space judges how big or small amount of memory (on primary/hard disks) is required to execute the algorithm. Depending on these two measuring criteria, two type of Algorithm Analysis are done; one is called Time Complexity Analysis and the second one is Space Complexity Analysis.
Which one is more important over the other?
I am sorry! I do not know the answer; rather there is no straight forward answer to this question. Think of yourself. Thinking of the previous example of many solutions that you have for travelling from your home to Esplanade, which criteria is most important? Is it Time of Travel, or is it Comfort? Or is it Financial Cost? It depends actually. While you are in hurry for shopping at New Market, the Time Taken would probably be your choice. If you have enough time in your hand, if you are in jolly mood and if you are going for a delicious dinner with your friends, probably you would choose Comfort; and at the end of the month, when you are running short with your pocket money, the Financial Cost would be most important to you. So the most important criterion is a dynamic notion that evolves with time.
Twenty or thirty years back, when the pace of advancement of Electronics and Computer Hardware was timid, computer programs were forced to run with lesser amount of memory. Today you may have gigantic memory even as RAM, but that time, thinking of a very large hard disk was a day dreaming! So at that time, Space Complexity was much more important than the Time Complexity, because we had lesser memory but ample times.
Now the time has changed! Now a day, we generally enjoy large memories but sorry, we don’t have enough time with us. We need every program to run as quick as possible! So currently, Time Complexity wins over Space Complexity. Honestly, both of these options are equally important from theoretical perspective but the changing time has an effect to these.
read lessLesson Posted on 05/07/2017 Learn BTech Information Science Engineering
What Are The Two Forms Of #Include?
Shiladitya Munshi
Well, I love spending time with students and to transfer whatever computing knowledge I have acquired...
Take BTech Tuition from the Best Tutors
Lesson Posted on 05/07/2017 Learn BTech Information Science Engineering
What Is the Difference Between Function And Subroutine?
Shiladitya Munshi
Well, I love spending time with students and to transfer whatever computing knowledge I have acquired...
Lesson Posted on 05/07/2017 Learn BTech Information Science Engineering
Shiladitya Munshi
Well, I love spending time with students and to transfer whatever computing knowledge I have acquired...
Are reference and pointers same?
No.
I have seen this confusion crumbling up among the student from the first day. So better clear out this confusion at thevery beginning.
Pointers and reference both hold the address of other variables. Up to this they look similar, but their syntax and further consequences are totally different. Just consider the following pieces of code
Code 1 Code 2
int i; int i;
int *p = &i; int &r = i ;
Here in code 1 we have declared and defined one integer pointer p which points to variable i, that is now , p holds the address of i.
In code 2, we have declared and defined one integer reference r which points to variable i, that is now, r holds the address of i. This is completely same as that of p.
So where is the difference?
The first difference can be found just by looking at the code. Their syntaxes!
Secondly the difference will come up when they would be used differently to assign a value (suppose 10) to i.
If you are using a pointer, you can do it like *p = 10; but if you are using a reference, you can do it like r = 10. Just be careful to understand that when you are using pointers, the address must be dereferenced using the *, whereas, when you are using references, the address is dereferenced without using any operators at all.
This notion leaves a huge effect as consequences. As the address of the variable is dereferenced by * operator, while using a pointer, you are free to do any arithmetic operations on it. That is you can increment the pointer p to point to the next address just by doing p++. But, this is not possible using references. So a pointer can point to many different elements during its lifetime; where as a reference can refer to only one element during its life time.
Does C language support references?
No. The concept of reference has been added to C++, not in C. So if you run the following code, C compiler will object then and there.
#include
#include
int main(void)
{
int i;
int &r = i;
r = 10;
printf("\n Value of i assigned with reference r = %d",i);
getch();
return 0;
}
But if you are using any C++ compiler, this code will work fine as expected.
If there is no concept of reference in C language, then how come there exists C function call by reference?
Strictly speaking, there is no concept of function call by reference in C language. C only supports function call by value. Though in some books ( I will not name any one) it is written that C supports function call by reference or the simulation of function call by reference can be achieved through pointers, I will strongly say that C language neither directly supports function call by reference, nor provides any other mechanism to simulate the same effect.
I know you are at your toes to argue that what about calling a C function with address of a variable and receiving it with a pointer? The change made to that variable within the function has a global effect. How this cannot be treated as an example of function call by reference?
You probably argue with a code like following
#include
#include
void foo(int* p)
{
*p = 5;
printf("\n Inside foo() the value of the variable: %d",*p);
}
int main(void)
{
int i = 10;
printf("\n before calling foo() the value of the variable: %d",i);
foo(&i);
printf("\n after calling foo() the value of the variable: %d",i);
getch();
return 0;
}
Your code will show the result as
Your points are well taken. But the thing is what you are showing is not at all calling a function by reference. It just the function call by value! Here you are essentially copying the value of address of your variable i and calling the function foo with that copy. Now eventually in this case, the value that is being passed contains the address of another variable. Within the function, you are accepting this value with a pointer and changing the value of the content addressed by that pointer. So it is nothing but a function call by value only.
Please note that to change the value of the content addressed by a pointer, you are to use *, no way could it be thought of as a reference.
Now let me give you one example of true function call by reference
#include
#include
void foo (int& r1)
{
r1 = 5;
printf("\n Inside foo() the value of the variable: %d", r1);
}
int main(void)
{
int i = 10;
int &r = i;
printf("\n before calling foo() the value of the variable: %d",i);
foo(r);
printf("\n after calling foo() the value of the variable: %d",i);
getch();
return 0;
}
Will this run with your C compiler? No.
Note:: I have used DevC++ as the coding platform
read less
Lesson Posted on 05/07/2017 Learn BTech Information Science Engineering
Some Interview Questions And Answers For Fresher Level On Pointers
Shiladitya Munshi
Well, I love spending time with students and to transfer whatever computing knowledge I have acquired...
Take BTech Tuition from the Best Tutors
Answered on 12/02/2017 Learn BTech Information Science Engineering
Prashanth Kannadaguli
BEST Technical Trainer & Freelancer
UrbanPro.com helps you to connect with the best BTech Tuition in India. Post Your Requirement today and get connected.
Ask a Question
The best tutors for BTech Tuition Classes are on UrbanPro
The best Tutors for BTech Tuition Classes are on UrbanPro