answersLogoWhite

0

📱

Computer Programming

A category for questions about computer programming and programming languages.

10,506 Questions

What are the Advantages of binary search on linear search in c?

(i) Binary search can interact poorly with the

memory hierarchy (i.e. caching), because of its

random-access nature. For in-memory

searching, if the interval to be searching is

small, a linear search may have superior

performance simply because it exhibits better

locality of reference.

(ii) Binary search algorithm employs recursive

approach and this approach requires more stack

space.

(iii) Programming binary search algorithm is

very difficult and error prone (Kruse, 1999).

What is object oriented programming and visual basic.net?

Yes, Visual basic uses Objects. I.E. buttons, options buttons, forms, text boxes, these are all objects in VB. VB also allows the creation and use of COM classes.

Visual basic is partially OOP as it does not support implementation inheritance, which is usually a feature of an object-oriented language.

What is the first in first out data structure?

In computer programming, first-in first-out (short FIFO) describes a data structure which implements a chronological order, such that when multiple elements are added to the data structure, the normal retrieval method returns the elements in the order in which they were added.

FIFO structures are often used to implement queues and buffers. The alternative commonly used chronological sorting container is LIFO, short for last-in first-out.

How do you compute the nth Fibonacci number using VBScript?

<html>

<body>

<script type="text/vbscript">

Dim a, b, c, n, nth

a = 0

b = 1

n = Cint(InputBox("Enter the value of ""n"""))

For nth = 1 to n Step 1

Document.Write(b&"<br/>")

c = a + b

a = b

b = c

Next

</script>

</body>

</html>

How do you draw a flowchart using case statement?

double discount; // Usually code would be read in char code = 'B' ; switch ( code ) { case 'A': discount = 0.0; break; case 'B': discount = 0.1; break; case 'C': discount = 0.2; break; default: discount = 0.3; } System.out.println ( "discount is: " + discount );

What programming language does YouTube use?

If your are thinking of youtube it uses a variety of languages. It defiantly uses flash and JavaScript for its front end and some sort of SQL for its data base. It uses several other languages too but those listed above are the only ones I am sure of.

Write an algorithm for quick sort?

#include <stdio.h>

#include <stdlib.h>

#define size 50

void swap(int *x,int *y)

{

int temp;

temp = *x;

*x = *y;

*y = temp;

}

int partition(int i,int j )

{

return((i+j) /2);

}

void quicksort(int list[],int m,int n)

{

int key,i,j,k;

if( m < n)

{

k = partition(m,n);

swap(&list[m],&list[k]);

key = list[m];

i = m+1;

j = n;

while(i <= j)

{

while((i <= n) && (list[i] <= key))

i++;

while((j >= m) && (list[j] > key))

j--;

if( i < j)

swap(&list[i],&list[j]);

}

// swap two elements

swap(&list[m],&list[j]);

// recursively sort the lesser list

quicksort(list,m,j-1);

quicksort(list,j+1,n);

}

}

void printlist(int list[],int n)

{

int i;

for(i=0;i<n;i++)

printf("%d\t",list[i]);

}

void main()

{

int n,i;

int list[size];

printf("How many numbers do you want to enter");

scanf("%d",&n);

printf("Enter the numbers you want to sort");

for(i=0;i<n;i++)

{

scanf("%d",&list[i]);

}

printf("The list before sorting is:\n");

printlist(list,n);

// sort the list using quicksort

quicksort(list,0,n-1);

// print the result

printf("The list after sorting using quicksort algorithm:\n");

printlist(list,n);

}

What causes internal fragmentation?

External fragmentation is the phenomenon in which free storage becomes divided into many small pieces over time.[1] It is a weakness of certain storage allocation algorithms, occurring when an application allocates and deallocates ("frees") regions of storage of varying sizes, and the allocation algorithm responds by leaving the allocated and deallocated regions interspersed.

How do you convert integer to float?

Sure especially in programming. Generally an int can be passed directly into a float.

Examples:

9 is an integer

9.00 is a float

in programming

int A = 9;

Float B = A;

What is difference between macro processor and macro assembler?

A macro processor processes macros. So what do you think a macro call does, play the flute. The answer is in the question and that begs the question of are you suited to computer programming specifically and an education in general. You are showing a marked reluctance to thinking.

What is const pointer?

In computer science, const-correctness is the form of program correctness that deals with the proper declaration of objects as mutable or immutable. The term is mostly used in a C or C++ context, and takes its name from the const keyword in those languages. The idea of const-ness does not imply that the variable as it is stored in the computer's memory is unwriteable. Rather, const-ness is a compile-time construct that indicates what a programmer may do, not necessarily what he or she can do. In addition, a class method can be declared as const, indicating that calling that method does not change the object. Such const methods can only call other const methods but cannot assign member variables. (In C++, a member variable can be declared as mutable, indicating that a const method can change its value. Mutable member variables can be used for caching and reference counting, where the logical meaning of the object is unchanged, but the object is not physically constant since its bitwise representation may change.) In C++, all data types, including those defined by the user, can be declared const, and all objects should be unless they need to be modified. Such proactive use of const makes values "easier to understand, track, and reason about," and thus, it increases the readability and comprehensibility of code and makes working in teams and maintaining code simpler because it communicates something about a value's intended use. For simple data types, applying the const qualifier is straightforward. It can go on either side of the type for historical reasons (that is, const char foo = 'a'; is equivalent to char const foo = 'a';). On some implementations, using const on both sides of the type (for instance, const char const) generates a warning but not an error. For pointer and reference types, the syntax is slightly more subtle. A pointer object can be declared as a const pointer or a pointer to a const object (or both). A const pointer cannot be reassigned to point to a different object from the one it is initially assigned, but it can be used to modify the object that it points to (called the "pointee"). (Reference variables are thus an alternate syntax for const pointers.) A pointer to a const object, on the other hand, can be reassigned to point to another object of the same type or of a convertible type, but it cannot be used to modify any object. A const pointer to a const object can also be declared and can neither be used to modify the pointee nor be reassigned to point to another object. The following code illustrates these subtleties: void Foo( int * ptr, int const * ptrToConst, int * const constPtr, int const * const constPtrToConst ) { *ptr = 0; // OK: modifies the pointee ptr = 0; // OK: modifies the pointer *ptrToConst = 0; // Error! Cannot modify the pointee ptrToConst = 0; // OK: modifies the pointer *constPtr = 0; // OK: modifies the pointee constPtr = 0; // Error! Cannot modify the pointer *constPtrToConst = 0; // Error! Cannot modify the pointee constPtrToConst = 0; // Error! Cannot modify the pointer To render the syntax for pointers more comprehensible, a rule of thumb is to read the declaration from right to left. Thus, everything before the star can be identified as the pointee type and everything to after are the pointer properties. (For instance, in our example above, constPtrToConst can be read as a const pointer that refers to a const int.) References follow similar rules. A declaration of a const reference is redundant since references can never be made to refer to another object: int i = 42; int const & refToConst = i; // OK int & const constRef = i; // Error the "const" is redundant Even more complicated declarations can result when using multidimensional arrays and references (or pointers) to pointers. Generally speaking, these should be avoided or replaced with higher level structures because they are confusing and prone to error.

On the computer system what is the difference of binary and decimal?

There is no difference. Decimal notation is merely a human convenience. The same rules that apply to decimal also apply to binary, the only difference being that decimal has 10 digits and deals with powers of 10, while binary uses 2 digits and deals with powers of 2. Binary (base-2) is the most primitive form of numeric notation and by far the simplest to implement at the machine level.

What are some of the new roles information system are playing in organization?

A management information system is a system that has important tools to supports, analyse, delivery and adding reliability to any organisation. Also this helps to solve businesses problems. The term MIS is often used to submit to a group of information management methods tied to the support of human decision making, e.g. Decision Support Systems, Expert systems, and Executive information systems.

What is dynamic RAM?

The RAM is like a dish holder. When required the disk is used and when the process is complete we keep the dishes back in its place again. Imagine the dishes to be empty spaces in the RAM. When a software or a program wants to run then a dish is utilised in the process and when the program is terminated the dish is again placed back in its place so that other programs can utilise the free space.

What are the different types of microcomputers?

) Desktop Personal Computer II) Laptop Personal Computer

III) Palmtop Computer / Personal Digital Assistant ( PDA)

IV) Workstation / Server

What are the function of flowcharts?

Flowchart and FunctionsThe source code is based on the MATLAB function simulate.m. The input arguments to simulate.m include the desired parameter values characterizing the human cardiovascular model and its execution, while the outputs are the simulated data - all pressures (), volumes (), flow rates ( ), ventricular elastances , adjustable parameters (), cardiac function/venous return curves (), and ventricular contraction times (). This function may also write the simulated data to file (with a desired prefix file name also provided as an input argument) and display the data as they are being calculated. The function is responsible for executing the models described in Section 2 as well as in Appendix A. However, the flowchart of Figure 7 depicts how the function simulates the data from the desired parameter values characterizing only the models of Section 2. The pertinent details of each block of the flowchart are provided below.

Figure 7: Flowchart of the MATLAB function simulate.m.

  • Declaring and Initializing Variables (t=0). With the desired parameter values provided as function input arguments, all variables of the simulation are declared and initialized. Memory is pre-allocated for all of the data to be simulated over their entire integration period in order to increase execution speed with the MATLAB compiler. The respiratory-related waveforms are pre-computed over the entire integration period.
  • Numerical Integration for Calculating . The pressures of the desired model of the pulsatile heart and circulation are calculated at the current time step () from the pressures at the previous time step () by fourth-order Runge-Kutta integration of the set of ordinary differential equations governing the model. must be set to 0.005 s for reasonable accuracy.
  • Adjusting Parameters by Regulation/Perturbations.Parameters of the pulsatile heart and circulation are adjusted by the short-term regulatory system and resting physiologic perturbations models. Because of the relatively narrow bandwidths of these models, the parameter adjustments are calculated at a sampling period of 0.0625 s. First, the requisite waveforms originally computed at a sampling period of are decimated to a sampling period of 0.0625 s by averaging over the past 0.25 s every 0.0625 s. Then, the mandated parameter adjustments are computed at a sampling period of 0.0625 s. Finally, the mandated parameter adjustments are converted to a sampling period of via linear interpolation (with the exception of the adjustments to which do not take effect until the initiation of the next ventricular contraction) in order to compute the subsequent waveforms.
  • Establishing qrs via``Integrate and Fire.'' The mandated changes to are mapped to the times of onset of ventricular contraction by integrating (in units of bps) over time until the integral is equal to one. Then, systole is initiated by resetting the variable, ventricular elastance model, the integral is set to zero, and the integration is repeated.
  • Heart-Lung Unit or Systemic Circulation? Varying , , and Averaging , . Cardiac function or venous return curves are generated, if desired. Following every fifth beat, and are varied in steps for generation of cardiac function curves, and is varied for simulation of venous return curves. Time-averaged and and (for cardiac function curves) are recorded over the beat preceding the step variation.
  • Calculating and Storing and . The blood volumes of each compartment of the desired model of the pulsatile heart and circulation are computed at the current time step from the pressures at the current time step, and the values of the ventricular elastances and adjustable parameters at the current time step are stored into their pre-allocated memory slots.
  • Intact Circulation? Correcting by Adjusting . Total blood volume of the intact pulsatile heart and circulation at the current time step ( ), which may vary due to integration error, is conserved. The difference between the computed and its assigned value is added/removed from and is altered accordingly.
  • Parameter Updates? Conserving and Documenting Updates.The parameter values of a simulation may be updated after the initiation of each ventricular contraction by pausing the simulation, updating the parameter values, and resuming the simulation. The newly chosen parameter values are documented to file if they are relevant to the current simulation, and the blood volumes in each compartment at the current time step are conserved by adjusting the pressures at the current time step (if necessary). Adjustments to the respiratory-related waveforms are implemented for the remainder of the integration period.
  • Calculating . The flow rates of the pulsatile heart and circulation models are calculated at the current time step from the pressures at the current time step.
  • On-Line Viewing? Writing Waveforms to MIT Format Files Displaying Waveforms. When viewing simulated data as they are being calculated, the waveforms are periodically written to file in MIT format (with a desired period). The newly written data are then immediately displayed with WAVE.

The flow of each of the blocks is then repeated starting at Numerical Integration for Calculating with . In order to execute the blocks in the flowchart, simulate.m calls upon many MATLAB and C functions, each of which are briefly described below.

  • intact_init_cond.m computes the initial pressures, volumes, and flow rates of the intact pulsatile heart and circulation model from the desired parameter values. The initial values are determined from the solution of a linear system of equations which are derived from the application of steady-state conservation laws to a linearized version of the model.
  • hlu_init_cond.m computes the initial pressures, volumes, and flow rates of the heart-lung unit preparation model from the desired parameter values. The initial values are determined from the solution of a linear system of equations which are derived from the application of steady-state conservation laws to a linearized version of the model.
  • sc_init_cond.m computes the initial pressures, volumes, and flow rates of the systemic circulation preparation model from the desired parameter values. The initial values are determined from the solution of a linear system of equations which are derived from the application of steady-state conservation laws to a linearized version of the model.
  • rk4.m computes the pressures of the pulsatile heart and circulation (any preparation) at the current time step from the pressures of the previous time step, the current values of the parameters, respiratory-related waveforms, and time surpassed in the current cardiac cycle according to fourth-order Runge-Kutta integration.
  • intact_eval_deriv.m is called only by rk4.m and computes the derivative of the intact pulsatile heart and circulation pressure values at a desired time step which is necessary for the fourth-order Runge-Kutta integration.
  • hlu_eval_deriv.m is called only by rk4.m and computes the derivative of the heart-lung unit preparation pressure values at a desired time step which is necessary for the fourth-order Runge-Kutta integration.
  • sc_eval_deriv.m is called only by rk4.m and computes the derivative of the systemic circulation preparation pressure values at a desired time step which is necessary for the fourth-order Runge-Kutta integration.
  • var_cap.m is also called by intact_eval_deriv.m, hlu_eval_deriv.m, and sc_eval_deriv.m and computes a ventricular elastance value as well as its derivative at a desired time step from the current values of , , the previous cardiac cycle length, and the time surpassed in the current cardiac cycle.
  • vent_vol.m is also called by intact_eval_deriv.m, hlu_eval_deriv.m, and sc_eval_deriv.m and computes the current ventricular blood volume from the current ventricular pressure according to Newton's search method with an initial guess given by the previous ventricular blood volume.
  • rand_int_breath.m computes the time until the next respiratory cycle commences based on the outcome of an independent probability experiment.
  • resp_act.m computes the respiratory-related waveforms (, , , and ) over the entire integration period from the parameter values and the times of commencement of each respiratory cycle.
  • ilv_dec.m decimates to a sampling period equal to 0.0625 s. This decimated waveform is convolved with the filter created by dncm_filt.m (see below) in order to establish the changes in mandated by the direct neural coupling mechanism.
  • dncm_filt.m generates a filter which characterizes the direct neural coupling mechanism between and .
  • bl_filt.m generates a lowpass filter with a narrow transition band (truncated sinc function of unit-area) and desired cutoff frequency which is utilized to bandlimit the exogenous disturbance to .
  • oneoverf_filt.m generates a filter with a 1/fmagnitude-squared frequency response over a desired frequency range (in decades) and at a desired sampling period (see below).
  • ans_filt.m creates a filter which is a linear combination of and . This filter is convolved with the filter generated by oneoverf_filt.m and then white noise in order to create the exogenous disturbance to .
  • abreflex.m computes the parameter adjustments mandated by the arterial baroreflex system based on the current setpoint and static gain values.
  • cpreflex.m computes the parameter adjustments mandated by the cardiopulmonary baroreflex system based on the current setpoint and static gain values.
  • param_change.m determines whether the parameter updates are relevant to the status of the current simulation based on the current parameter values, the previous parameter values, and the status parameters (see Section 5.2).
  • conserve_vol.m computes the pressures at the current time step necessary to conserve the blood volume in each compartment at the current time step when parameter values are updated.
  • read_param.m reads a file which contains the parameters values of the cardiovascular model and its execution in a specific format and stores the values in a MATLAB vector.
  • read_key.c reads the standard input, pauses the simulation if a ``p'' is entered followed by RETURN, and resumes the simulation if a ``r'' is entered followed by RETURN.
  • write_param.c copies the parameter file to a new file of the same name but with the extension .num. This function is implemented when the parameter update occurs. The extension is set equal to the number of parameter updates that have been made during the simulation period.
  • wave_remote.c plots the desired simulated waveforms and annotations with the WAVE display system. This function is called when the simulated data are written to file in MIT format and plots the most recent desired window of written data.

The function simulate.m is called by a wrapper function rcvsim.m for execution at the Linux prompt. This wrapper function takes two command line arguments: 1) the name of a file containing the desired parameter values and 2) the prefix name of the output files to be generated in MIT format. The function rcvsim.m, which also includes a help option, reads in the parameter file with read_param.m (see above), creates a header file in MIT format, executes simulate.m, writes the simulated data to MIT format files if the on-line viewing option is not chosen, and displays cardiac function and venous return curves, if desired, with the function plot_cfvr.c (which employs Gnuplot). In order to execute rcvsim.m, the function must be compiled with the filemake.m which creates the binary file rcvsim. The function simulate.m may also be compiled independently of rcvsim.m with the file makem.m which creates the binary file simulate.mexlx (in the Linux environment). Each of these make files greatly improve execution speed specifically through mcc (MATLAB compiler) optimization arguments r (real numbers only) and i(no dynamic memory allocation). Note that simulate.m may only be executed in the MATLAB environment without on-line viewing and parameter updating capabilities.

Where do you find instances in World of Warcraft?

Instances in WoW are all over the place. Theres one in the Barrens near Thunderbluff, theres one in Westfall, one in Dun Morogh, theres one actually inside a Capital city: Stormwind City. So.... Just look around cause the instances are all over the place.

Why in copy constructor in c you use pass by reference?

Because if it's not by reference, it's by value. To do that you make a copy, and to do that you call the copy constructor. But to do that, we need to make a new value, so we call the copy constructor, and so on...

(You would have infinite recursion because "to make a copy, you need to make a copy".)

How can you use hacking in c program?

That entirely depends on what you want it to do, however it is easy to send commands to the command line using subprocess.Popen(), read files and modify them or back them up using the built in open(), or delete files.

Did this answer your question?

Write an algorithm to find max of 10 numbers?

Someone's coursework?! This function is for an array of integers, the length of the array is Count.

int MaxInt(NumArray as *int, Count as int)

{

int Inst;

int Result;

Result = NumArray[0];

for (Inst=0;Inst

{

if(NumArray[Inst] > Result)

{

Result = NumArray[Inst];

}

}

return Result;

}

Why multithreaded programming is beneficial over single threaded programming?

Not having multithreading is like only having one arm and one gram of brain tissue. Multithreading is essential to computer application operation.

Multithreading allows a computer to:

* Distribute processing power over various applications, allowing multiple programs to run at the same time. * Allow a program to run non-essential processes in the background while the main application continues to run normally without hold-ups. * Manage timing of different events without making the process too complicated. For example, say that you have an application that does text editing and plays music. You would want to run the text editor part and the music playing part on separate threads, because otherwise, when the text editor got to a computation-intensive stage, the music would be slower, and when the text editor was idle, the music would be faster.

This is also what allows the computer to run multiple applications at once. If the computer could not distribute processing power over multiple applications, then you could not run multiple instances of a text editor, or an internet browser, or really anything. Really, nothing would be possible because the system resources would monopolize the processor.

In reality, this is how the processor handles threads: it goes around and devotes some time to each one, then moves on to the next. It "rounds the bases" so fast, like a cathode ray tube TV, that we don't notice the different. Duel (and triple, and quad, etc.) core processors allow one to split the applications and their corresponding threads to operate on different processors, affecting how much processing power they each receive.

Different graphics functions in'C' language?

There are no built in or standard graphics library with the original C language. The BGI library graphics.h has many functions for borland graphics. windows.h is another header file for creating user interfaces in windows.