What is the circumferance of a 12' diameter circle?
The circumference of a circle equals 2(pi)r where pi = 3.142 and r = radius. In this case we know diameter not radius, but remember that diameter = 2r, so 12 = 2r r = 6 Plugging this back into our first equation we get: 2(3.142)(6) Circumference = about 37.7 feet
WAP to show the difference between a variable and static variable?
difference between constant and static variables in java
What is the essence of heap sort?
The essence of heap sort is the heap.
A heap is a complete binary tree. That is; every parent node has two child nodes except the last parent which may have either one or two children depending on the total number of nodes. The last parent in the heap is always the rightmost parent on the lowest level. The minimum size of a heap is 2 elements.
The primary property of a heap is that every parent's value is greater-than or equal-to the values of its child or children. This means that the root node (the top of the heap) always holds the largest value in the heap.
Child nodes are denoted as left and right but the final parent need not have a right child. Where both are present, no order is specified. That is; the left child can either be less-than, equal-to or greater-than the right child. Although it is possible to specify an order (such that left is always less-than or equal to right), there is no benefit in doing so.
Heap sort requires random access and is therefore most efficiently implemented using an array. Sorting can be done in-place in logarithmic time and with minimal space overhead but, like quicksort, it is not stable (equal elements may not be in the same order they were input). While somewhat slower than quick sort, in practice it has a more favourable worst-case of O(n log n).
Heap sort can also be thought of as being an improved selection sort. Like selection sort, the input set is divided into two, with an unsorted set and a sorted set, extracting the largest value from the unsorted set and placing it in the sorted set. However, selection sort requires a linear-time search to locate the largest value, whereas heap-sort can achieve this in constant time (because the largest value is always at the top of the heap). The main overheads are in the initial construction of the heap (which takes linear time) and in repairing the heap after extracting each value (which is logarithmic). Selection sort is reasonably efficient when working with small sets (although an insertion sort is usually more efficient) while heap sort is much better for larger sets but still somewhat slower than quick sort in practice.
An array provides the most compact and efficient storage of a heap because the structure of the heap (the actual links between any child and its parent, in either direction) can be computed using trivial arithmetic. That is; given the zero-based index of any element within the heap, we can determine the indices of the parent and the left and right child as follows:
parent = floor ((index - 1) / 2)
left = 2 * index + 1
right = 2 * index + 2
[The floor function is a standard function which returns the largest integer that is not greater than its argument. That is, floor(0.9) will always return the integer 0 rather than "round up" to 1, because 1 would be greater than 0.9].
Heap sort makes use of two helper functions, one to construct the initial heap and the other to repair the heap each time we extract the largest value (the root value).
The repair algorithm is known as a "sift down" and this requires that we pass the index of the parent to be sifted as well as the index of the last value in the heap. The index of the last value is important because if we pass the index of the last parent in the current heap and that parent has no right child, the "right" equation would produce an index that is greater than the last index, so we must guard against that. Leaf nodes have no children, but the algorithm is such that we never pass the index of a leaf node, so we don't need to guard against the "left" equation producing an invalid index.
The purpose of the sift down algorithm is to examine the parent value with its child value(s) to determine which is the largest. If the parent holds the largest, the algorithm does nothing (the heap is valid for that particular parent). Otherwise, it swaps the parent value with the largest child and if the child is not a leaf, repeats the process for that child. In other words, the original parent value finds its correct place within the heap rooted by that parent.
Construction is an iterative algorithm known as "heapify" that traverses the unordered set in reverse order from the back of the array. On each iteration we locate the parent of the current index, thus we can ignore index 0 since it has no parent (it is the root). Once we have located the parent, we perform a repair (a sift-down) with that parent. Since we work from the back of the array, the heap is effectively built from the bottom up, one layer at a time, with lower values sifting down and thus forcing larger values up. The final iteration places the largest value in the root.
Thus, given an array, a, with n elements, we can implement the heap sort algorithm as follows (in pseudocode):
heapify (a, n)
end = n - 1
while end > 0 do
{
swap (a[0], a[end])
end = end - 1
sift_down (a, 0, end)
}
Given an array a with n elements, the heapify algorithm can be implemented as follows:
start = floor ((n - 2) / 2)
while start >= 0 do
{
sift_down (a, start, n - 1)
start = start - 1
}
Finally, given an array a, with a heap rooted at index start and a last value at index end, the sift_down algorithm can be implemented as follows:
root = start
while root * 2 + 1 <= end do
{
left = root * 2 + 1
swap = root
if a[swap] < a[left] then swap = left
right = left + 1
if right <= end and a[swap] < a[right] then swap = right
if swap == root then return
swap (a[root], a[swap])
root = swap
}
In an if statement what must enclose the condition?
In an if statement, the condition must be enclosed in parentheses.
What is the purpose of the IMDG code?
• Enhance the safe transport of dangerous goods
• Protect the marine environment
• Facilitate the free unrestricted movement of dangerous
goods
Write a program in Lex to eliminate white space and collect numbers as a token?
write a lex program to delete space from the program
What are the advantage and disadvantage of organizing an event?
There are many advantages of event driven programming. This type of programming is the simplest and flexible forms of programming languages. This means the programmer has more control over the program when the user does something. Also, making an event driven program is easy.
There are only a few disadvantages that come with the event driven programming. Firstly, sometimes classes are not often reusable and are hard to carry out in other applications. It is also very complex and hard to master.
What does the ComboFix program do?
ComboFix is a program that scans a computer for malware or other malicious programs such as spyware and attempts to clean them up automatically. It seems to be a reputable program with decent ratings.
What is the purpose of the comma operator in GWBASIC?
The GWBASIC comma operator is used to format the output of the PRINT command, placing the value to be printed in the next print zone rather than immediately after the previous value. Note that GWBASIC divides each line into zones of 14 spaces each.
The comma operator also has other purposes, such as when filling a string with the same character. For example:
10 X$ = STRING$(10,45)
20 PRINT X$"HELLO WORLD"X$
RUN
----------HELLO WORLD----------
The comma operator is also used to separate the dimensions of a multi-dimensional array, such as the following 2x3 array:
A(2,3)
What does it mean when there is a decimal right after echo no space on a batch file?
A period right after the "echo" command would echo an empty line.
Comparison of C' malloc and free functions with c new and delete operators?
Hi, The difference between new and malloc: 1.The New is a operator however malloc is a function 2.New returns the object type and there is no typecasting required. In malloc type casting should be done as it returns a void*. 3. The new operator can be overloaded however there is no over loading in C and hence Malloc can not be overloaded. 4. Operater New asks for the number of objects to be allocated however in malloc it will ask you for the number of bytes to be allocated. 5. The New operater will return you a exception of memory is not available however in malloc it will return u a NULL. 6. New is a concept for dynamically allocation in OOPS(C++) however malloc is used in C. The difference between the delete and free is as follows: 1. delete is a operator and can be overloaded however free is a function and can not be overloaded. With Regards, Shashiraja Shastry
What works with one source statement at a time translating it to machine level instructions?
Are you asking about an "interpreter"? That's part of a computer language that reads a line of code and breaks it down into machine code.
The Interpreter works with one source statement at a time, reading it, translating itto machine-level instructions, executing the resulting binary instructions, and then moving on to the next source statement.
Almost no real interpreters generate any machine code, they simply interpret the source code and directly do what it says using machine code built into the interpreter when it was originally written.
Machine code is generated by compilers, to permit repeated execution without having to reload the compiler each time (as one must with an interpreter).
Is late binding and dynamic binding related to polymorphism?
Late binding and dynamic binding are related to runtime polymorphism. By contrast, compile time polymorphism is known as static binding. Template functions and classes are examples of static binding because the exact type can be determined at compile time.
A Delphi unit is a separate file used to store procedures and functions. If you know what a form is, a unit is exactly the same, except it has no visual interface. So you can't put windows controls on it like buttons and edit boxes. A form has windows controls and their associated code behind them, a unit only has the code.
They are useful if you have some functions that you use often from many different forms and you only want to write them once. For example:
function LeftStr(const S : String; Index : Integer) : String;
begin
If Index <= 0
then
Result := ''
else
Result := Copy(S, 1, Index);
end;
function RightStr(const S : String; Index : Integer) : String;
begin
If Index > Length(S)
then
Result := ''
else
Result := Copy(S, Index, (Length(S)-Index+1));
end;
Then you can have your unit's name in a forms uses clause and then use the functions LeftStr and RightStr from several different forms.
Find vowel from given string in C plus plus language?
std::string test ("The cat sat on the mat");
std::string vowels ("aeiouAEIOU");
size_t pos = test.find_first_of (vowels);
if (pos != test.npos)
std::cout << "Vowel found at position " << pos << std::endl;
The command used to execute a BASIC programme?
Assuming a BASIC program is loaded into memory, the correct command to execute a BASIC program is: RUN. If you would like to start your program at a particular point in the execution, you may use RUN [#], where [#] is the line number you would like to start execution at.