#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct node
{
int n;
struct node *ptr;
};
int main(void)
{
struct node *n1,*strt,*temp;
char a;
int cnt=0,i=0;
//char a[50],temp[100],line[100],word[50],e[50],final[100];
//FILE *fp,*fp1,*fp2;
strt=malloc(sizeof(struct node));
strt->n=90;
strt->ptr=NULL;
for(a='y';a!='n';)
{
n1=malloc(sizeof(struct node));
n1->n=++cnt;
n1->ptr=strt;
strt=n1;
scanf("%c",&a);
}
// ptr[1]=40;
// ptr[2]=30;
n1=strt;
while(n1!=NULL)
{ printf("\n %d at loc %p",n1->n,n1);
printf(" locaa %p \n",n1->ptr);
n1=n1->ptr;
}
return 0;
}
~
~
~
An AVL tree is another balanced binary search tree. Named after their inventors, Adelson-Velskii and Landis, they were the first dynamically balanced trees to be proposed. Like red-black trees, they are not perfectly balanced, but pairs of sub-trees differ in height by at most 1, maintaining an O(logn) search time. Addition and deletion operations also take O(logn) time.
Definition of an AVL treeAn AVL tree is a binary search tree which has the following properties:What is difference between a source program and an object module?
An object program is a compiled program ready to be loaded on a computer,
i.e. machine code, ready to be executed by the machine.
A source program is what the programmer wrote, which is then translated into object program by a compiler.
Is B tree a Binary Search Tree?
Yes because there is no real practical use for a binary tree other than something to teach in computer science classes. A binary tree is not used in the real world, a "B tree" is.
prime a loop is that how mach time it executed either max time or minimum time
The American Standard Code for Information Interchange was made to standardize 128 numeric codes that represent the English letters, Symbols, and Numbers. Any USA keyboard is made with this standard in mind.
How do you fix an infinite loop?
It comes from its name: it doesn't terminate, the user have to interrupt the program-run (in the worst case: power off the computer).
The infinite loop is also used to program loops with non-easily-deterministically end-of-loop conditions.
You write an infinite loop, such as for (;;) {statements}, and break out of the loop with the break statement when ready to terminate.
Why do you need assembly language?
Assembly language is more human-readable than machine language. Generally, statements in assembly language are written using short codes for the instruction and arguments, such as "MOV $12 SP", as opposed to machine language, where everything is written as numbers. Assembly language can have comments and macros as well, to ease programming and understanding.
Generally, programs called "assemblers" transform assembly language to machine language. This is a relatively straightforward process, there being a clear 1-to-1 transformation between assembly and machine language. This is as opposed to compilers, which do a complicated transformation between high-level language and assembly.
--------------------------------------------------------------------
ASSEMBLY is the key word to define the difference between Machine Language and Assembly. . Assembly language assembles steps of MACHINE CODE into SUB-ROUTINES defined by simple text words:
Such as: the assembly command 'ADD' may represents 20-30 machine commands.
Write a c program to merge two array?
#include <stdio.h>
#include <conio.h>
void main(){
int a[10],b[10],c[10],i,j,m,n,tmp,k;
printf("\nEnter the size of the 1st array:");
scanf("%d",&m);
printf("\nEnter the size of the 2nd array:");
scanf("%d",&n);
printf("\nEnter the 1st array values:");
for(i=0;i<m;i++){
scanf("%d",&a[i]);
}
printf("\nEnter the 2nd array values:");
for(i=0;i<n;i++){
scanf("%d",&b[i]);
}
for(i=0;i<m;i++)
{
for(j=0;j<m-i;j++)
{
if(a[j]>a[j+1])
{
tmp=a[j];
a[j]=a[j+1];
a[j+1]=tmp;
}
}
}
printf("\n\n Array in the ascending order is - \n");
for(i=0;i<m;i++)
{
printf("\t %d",a[i]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(b[j]>b[j+1])
{
tmp=b[j];
b[j]=b[j+1];
b[j+1]=tmp;
}
}
}
printf("\n\n Array in the ascending order is - \n");
for(i=0;i<n;i++)
{
printf("\t %d",b[i]);
}
i=j=k=0;
while(i<n&&j<m)
{
if(a[i]<b[j])
c[k++]=a[i++];
else
if(a[i]>b[j])
c[k++]=b[j++];
else
{
c[k++]=b[j++];
i++;
j++;
}
}
if(i<n)
{
int t;
for(t=0;t<n;t++)
c[k++]=a[i++];
}
if(j<m)
{
int t;
for(t=0;t<m;t++)
{
c[k++]=b[j++];
}
}
printf("\nFinally sorted join array is:");
for(k=0;k<(m+n);k++)
printf("\t\n %d ",c[k]);
getch();
}
We briefly list some of C's characteristics that define the language and also have lead to its popularity as a programming language. Naturally we will be studying many of these aspects throughout the course. * Small size * Extensive use of function calls * Loose typing - unlike PASCAL * Structured language * Low level (BitWise) programming readily available * Pointer implementation - extensive use of pointers for memory, array, structures and functions. C has now become a widely used professional language for various reasons. * It has high-level constructs. * It can handle low-level activities. * It produces efficient programs. * It can be compiled on a variety of computers. Its main drawback is that it has poor error detection which can make it off putting to the beginner. However diligence in this matter can pay off handsomely since having learned the rules of C we can break them. Not many languages allow this. This if done properly and carefully leads to the power of C programming. The standard for C programs was originally the features set by Brian Kernighan. In order to make the language more internationally acceptable, an international standard was developed, ANSI C (American National Standards Institute).
What are the algorithm in stopwatch c language?
#include <stdio.h>
#include <time.h>
int main()
{
time_t start_time;
time_t stop_time;
int e;
clrscr();
printf( "Type the Enter key to START timing.\n");
while(getchar()!='\n');
start_time=time(NULL);
printf( "Type the Enter key to STOP timing.\n");
while(getchar()!='\n');
stop_time=time(NULL) ;
e=difftime( stop_time,start_time);
printf( "Elapsed time: %d seconds.\n" ,e) ;
getch();
}
What is the main function of the spline?
the purpose of the spline is to support the weight of your head
What are the advantages of using a recursive function in c?
Advantages:
Through Recursion one can Solve problems in easy way while
its iterative solution is very big and complex.
Ex : tower of Hanoi
You reduce size of the code when you use recursive call.
Disadvantages :
Recursive solution is always logical and it is very
difficult to trace.(debug and understand)
Before each recursive calls current values of the varibles
in the function is stored in the PCB, ie process control
block and this PCB is pushed in the OS Stack.
So sometimes alot of free memory is require for recursive
solutions.
Remember : whatever could be done through recursion could be
done through iterative way but reverse is not true.
What is the difference between database and relational database?
A database is something that stores data. Using tools called Database Management Systems(like Oracle, Informix, Sybase, DB2), you can create, view, modify, and delete databases. Databases can be -Relational -Object Oriented -Object Relational Relational database stores data in tables(called realtions). These tables are related to each other.Just like in our family, our relations are related with each other. In Object Oriented Databases, the information is stored in the form of Objects as in Object Oriented Programming.OODBMS makes database objects appear as programming language objects in one or more porgramming languages. Object relational databases combine the features of both Object Oriented as well as Relational databases. Here you can not only store simple data like text in relational, but you can also store complex objects like images, audio and video in tables.
Q1 Find the minimum and the maximum number of keys that a heap of height h can contain?
Q1. Find the minimum and the maximum number of keys that a heap of height h can contain.
Progarm to delete previous node in linked list?
struct LinkedListNode
{
void* data;
LinkedListNode* next;
};
LinkedListNode* head;
LinkedListNode* tmp;
while (head)
{
tmp head->next;
free(head);
head tmp;
}
Can you Write a program in c plus plus to display the multiplication table?
void printTable() {
}
printf("\n");
printf(" ");
for (c = 0; c <= 10; ++c) {
printf(" -");
}
printf("\n");
// calculations
int r;
for (r = 0; r <= 10; ++r) {
// row headers
printf("%2d|", r);
// calculation for the current row
for (c = 0; c <= 10; ++c) {
printf("%4d", (r * c));
}
printf("\n");
}
}
How do you Assign an address to an element of pointer array?
Pointers were always difficult subject to understand. I would suggest to read several tutorials and spend some time playing with them.
Explanation:
/* create array of two pointers to integer */
int *aaa[2];
/* setting first pointer in array to point to 0x1212 location in memory */
aaa[0] = (int *)0x1212;
/* allocate memory for the second pointer and set value */
aaa[1] = malloc(sizeof(int));
*aaa[1] = 333;
/* if you want to can make first item to point to the second,
now arr[0] pointer address changed to the same as aaa[1] pointer */
aaa[0] = aaa[1];
/* print aaa[1] address and later print value */
printf("LOCATION: %X\n", (unsigned int)*(aaa + 1));
printf("VALUE: %d\n", **(aaa + 1));
/* exact the same here, but different way of how I wrote pointers */
printf("LOCATION: %X\n", (unsigned int)aaa[1]);
printf("VALUE: %d\n", *aaa[1]);
If you would do the same with 0 element of array, which points to 0x1212 memory location you would get some kind of number or Bus error if you accessed restricted memory place (for example the beginning of memory).
I hope this I did not make you more confused than you are.
Second-generation programming language is a generational way to categorize assembly languages. The term was coined to provide a distinction from higher level third-generation programming languages (3GL) such as COBOL and earlier machine code languages. Second-generation programming languages have the following properties:
* The code can be read and written by a programmer. To run on a computer it must be converted into a machine readable form, a process called assembly.
* The language is specific to a particular processor family and environment.
Second-generation languages are sometimes used in kernels and device drivers (though C is generally employed for this in modern kernels), but more often find use in extremely intensive processing such as games, video editing, graphic manipulation/rendering.
One method for creating such code is by allowing a compiler to generate a machine-optimized assembly language version of a particular function. This code is then hand-tuned, gaining both the brute-force insight of the machine optimizing algorithm and the intuitive abilities of the human optimizer.
Advantages and disadvantages of low level language?
Programs written in low level language are executed immediately. They require no compilers.
Low Level Language instructions can be used to manipulate the individual bits in a byte of computer storage.
DisadvantagesAre machine dependentdifficult to program.
Impossible for the programmer to memorize all the operational codes.
Correcting and modifying a program is difficult.
10 REM Sample BASIC Program - Counts To Ten 20 REM 30 REM Copyright 2005 Andrew Eichstaedt 40 REM Eichstaedt Development Group 50 REM http://www.andrew-eichstaedt.com 60 REM 70 PRINT "Hello! I am a sample BASIC program" 80 PRINT "that counts to ten." 90 PRINT 100 FOR I=1 TO 10 110 PRINT I 120 NEXT I 130 PRINT 140 PRINT "Thanks for running me." 150 END
C program to find prime number?
I am providing a succinct and easy to understand version of the program. I have run it in 3-4 compilers and it works perfect. Mind you, you should not enter a number more than 2147483647 (which is the largest number a variable can process in C!). If you do, no problem, but it will display all numbers above it, including the even numbers to be prime. So here you are:
#include
#include
main()
{
long int a,b,c;
printf("Enter the number: ");
scanf("%ld",&a);
An array name is a pointer constant?
An array's name is not a constant pointer; it's not even a pointer! An array name is a reference to the array itself. Unlike pointers, references have no memory of their own, therefore a reference cannot be constant (only what it refers to can be constant). A reference is nothing more than an alias for a memory address. Since there is no separate storage for references, you cannot reassign references while they remain in scope. So, in that sense, it behaves like a constant pointer. But a pointer is a variable, so even if declared const, it requires memory of its own in order to store the memory address it points to.
Example:
int a[10];
int * const p = a; // const pointer
assert( *p &a ); would cause an assertion. Likewise, assert( p != &p); proves that p must reside in a separate memory address from that referred to by a. It has to: pointers are variables even when they are declared const.
What are the Real time examples for non linear data structures?
In Systematically search option (Depth First Search), Data storing and retrieving in hard disk based on the "BALANCED TREE(AVL
- B- TREE)", printer (QUEUE),
In Programming language point of with out Data structure and Algorithms we can't develop a single program -
primitive data structures - INTEGER, FLOAT, CHAR , BOOLEAN, ETC..
abstract data structures- ARRAY , LINKED LIST , GRAPH, TREE, STACK , QUEUE. ETC..
So, In programming every where we are using without knowing about this...
try to learn basic thing about programming ....for to become a Good Software Engineer you should know the fundamental of Data Structure and Algorithms.