answersLogoWhite

0

📱

Computer Science

Computer Science is the systematic study of algorithmic processes that describe and transform information. It includes the theoretical foundations of information and computation and the practical techniques of applying those foundations to computer systems. Among the many subfields of Computer Science are computer graphics, computer programming, computational complexity theory, and human-computer interaction. Questions about Computer Science, terms such as algorithms and proofs, and methodologies are encouraged in this category.

1,839 Questions

What do you mean by Microsoft Excel?

Microsoft is a brand like Addidas or Prada. Excel is a programme that you use for producing spreadsheets.

What is the purpose of a spiral bot?

The purpose of a spiaral bot is to drive around the city, playing music to entertain, as well as "scoping out."

How are computers helpful in human resources?

Computers have become extremely helpful in human resource management. They are now used to store employee information, to track employee attendance (for example, www.gradience.com) and absences (for example, www.tracksmart.com), and to let managers know when an employee is due for an annual review or a raise. Many companies use computer programs to test job applicants, while others offer online training to bring new employees up to speed on critical skills.

Computers track employee hours worked and then compute pay, including deductions for complicated tax rates, health insurance, and other employee deductions.

And of course, computers are used in word processing and spreadsheet creation, to allow human resource managers to do everything from create employee handbooks to compare costs for suppliers.

There are probably a few small businesses that don't use computers for their human resource management functions, and prefer to use paper time sheets and handwritten or typed forms. But these holdouts are fewer each year, as computers become the norm for almost all HR activities.

Why should you use private attribute and example?

The "private" attribute causes the method, object, or class to which it is applied to become inaccessible to code outside of its "private" scope. This means that a compiler will issue an error if any code outside of the "private" scope attempts to access the method, object, or class that is marked as private. You should use this when you wish to ensure that your data's integrity is maintained when other code could use it.

Some common industry examples: singleton objects (only one may exist at any time), a class that manages its internal state would use only accessor and mutator functions to allow outside code access (known as encapsulation, a foundation of object-oriented programming; often called a class' API), and business logic protection (by restricting certain functions to only a formal instance of a class, and not its subclasses).

Has any computer ever passed the Turing Test?

No. See the related links section for a link to the Loebner Prize website, which awards $5,000 annually for the chatbot which is "most indistinguishable from a human." There is still $100,000 reserved from Dr. Loebner for the first chatbot to actually pass the Turing test.

Implement full subtractor with two half subtractors and OR gate?

You use the first HS with entries of x0 and y0 . then you get D0=X0 XOR Y0

and B0=X0 NOT*Y0.(*=AND)

Then you use the sacond HS with entries of D0(from the first HS) and B-1(borrow from the previous level). then you get D1=X0 XOR Y0 XOR B-1(exactly like D in FS)

and B1=D0 NOT*B-1.

Then you use the OR gate with entries B0(from the first HS) and B1(from the second HS) and you get B=B0 OR B-1 AND D0 NOT. If you check the options you can get their similar to the borrow of FS

What is the difference between high level language and low level language?

A programming language that is machine-independent is called a "high-level" language - this includes Java, C++, Python, etc.

A programming language that is machine-dependent is called a "low-level" language. For PCs, this usually includes assembly, binary code or some proprietary languages on embedded devices.

What mechanism would you implement in the process scheduler to automate the termination of a job that is in an infinite loop?

put a counter in. set it to zero before the loop. add 1 to it inside the loop pick a realistic number for how many times it could possibly go through legitamately and have it exit the loop if the counter goes above that.

or if you do not have duplicate data each time through the loop save the data compare it the next time through and if it is the same 2 or 3 times in a row abort the loop.

Why wr are using c programming?

C/C++ is used to write system softwares. The whole of UNIX operating system is written in C language.

What are the advantages and disadvantages of sampling a signal?

Sampling a signal is a process where some thing, usually an analog signal, is sampled at a particular frequency, and analysis and processing is performed on that sample stream. The advantages are that conversion between the time domain and the frequency domain using Fourier analysis is a very powerful technique that allows you to do a lot of different things, such as compression and filtering, without needing advanced electronics. You can also transmit the digital samples from one point to another, using digital electronics, rather than analog electronics. Disadvantages are that sampling, by its very nature, introduces distortion, because you have limited resolution on the ADC and you have limited frequency of sample rate. Often, however, you can do very well, so long as you understand the implications of sampling. One of them is called Nyquist Aliasing. That is where the sample rate is less than the Nyquist frequency of one half of the highest harmonic of the signal. This is a very noticeable distortion, perceived as a buzzing in inverse frequency terms, which must be properly filtered. In fact, if you look at a traditional audio CD, the sample rate is 44.1 KHz, making the Nyquist frequency 22.05 Khz. That is commonly above the range of human hearing, but you still must account for it, otherwise, the distortion could damage the equipment or degrade the signal quality.

Where can i get unreal engine 2?

Go to:

http://unrealtechnology.com/features.php?ref=past-versions

What is modification record in system software?

Modification record contains the information about the modification that has to be done in the object code during program relocation.

The general format is

Col 1: M

Col 2-7: starting location of the address field to be modified relative to the beginning of the program

Col 8-9: length of the address field to be modified in half bytes.

Calculate the Time and Space complexity for the Algorithm to add 10 numbers?

The algorithm will have both a constant time complexity and a constant space complexity: O(1)

What is a symbolic constant in c language?

symbolic constants are constants represented by symbols....

constants are values that does not change through out the program execution.

e.g

#include<stdio.h>

#include<conio.h>

#define NUM 15

void main()

{

int a=NUM;

printf("The constant is %d",a);

getch();

}

here #define is a preprocessor. its job is to replace all the entries named NUM as 15. So that the compiler works with the constant 15...

In Java you want to write a program that will prompt the user for a nonnegative value n the program will then do as follows in the discussion help please?

// Set up a Scanner class to read from standard input
final Scanner in = new Scanner(System.in);

// Prompt for input and read the next integer
System.out.print("Please enter a positive integer: ");
int n = in.nextInt();

// Since we want to print out n lines, iterate n times
for (; n > 0; --n) {

// On each iteration, print out the numbers [1,n]
for (int i = 1; i <= n; ++i) {
System.out.print(i + " ");

}
System.out.println();

}

// Remember to close open resources when we're done.
in.close();

Write a program to implement tower of hanoi in openGL?

/*Answer by weerdhaval chowgule this is the new edited version of the previous certain errors in push function and headers are included */

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include<iostream>

#include <glut.h>

using namespace std;

double WIDTH = 800;

double HEIGHT = 800;

GLboolean motion = GL_TRUE;

GLboolean back_wall = GL_FALSE;

GLint xangle = 0, yangle = 0;

GLint xlangle = 0, ylangle = 0;

#define other(i,j) (6-(i+j))

#define wallz -(WIDTH/2)

#define DISK_HEIGHT 20

int NUM_DISKS = 5;

#define CONE NUM_DISKS+1

#define WALL CONE + 1

#define HANOI_SOLVE 0

#define HANOI_QUIT 1

#define HANOI_LIGHTING 2

#define HANOI_WALL 3

#define HANOI_FOG 4

GLfloat lightOneDirection[] =

{0, 0, -1};

GLfloat lightOnePosition[] =

{200, 100, 300, 1};

GLfloat lightOneColor[] =

{1.0, 1.0, 0.5, 1.0};

GLfloat lightTwoDirection[] =

{0, 0, -1};

GLfloat lightTwoPosition[] =

{600, 100, 300, 1};

GLfloat lightTwoColor[] =

{1.0, 0.0, 0.3, 1.0};

GLfloat lightZeroPosition[] =

{400, 200, 300, 1};

GLfloat lightZeroColor[] =

{.3, .3, .3, .3};

GLfloat diskColor[] =

{1.0, 1.0, 1.0, .8}, poleColor[] =

{1.0, 0.2, 0.2, .8};

typedef struct stack_node {

int size;

struct stack_node *next;

} stack_node;

typedef struct stack {

struct stack_node *head;

int depth;

} stack;

stack poles[4];

void

push(int which, int size)

{

int i;

stack_node *n = (stack_node* ) malloc(sizeof(stack_node));

if (!n) {

fprintf(stderr, "out of memory!\n");

exit(-1);

}

n->size = size;

n->next = poles[which].head;

poles[which].head = n;

poles[which].depth++;

}

int

pop(int which)

{

int retval = poles[which].head->size;

stack_node *temp = poles[which].head;

poles[which].head = poles[which].head->next;

poles[which].depth--;

free(temp);

return retval;

}

typedef struct move_node {

int t, f;

struct move_node *next;

struct move_node *prev;

} move_node;

typedef struct move_stack {

int depth;

struct move_node *head, *tail;

} move_stack;

move_stack moves;

void

init(void)

{

int i;

for (i = 0; i < 4; i++) {

poles[i].head = NULL;

poles[i].depth = 0;

}

moves.head = NULL;

moves.tail = NULL;

moves.depth = 0;

for (i = 1; i <= NUM_DISKS; i++) {

glNewList(i, GL_COMPILE);

{

glutSolidTorus(DISK_HEIGHT / 2, 5 * i, 15, 15);

}

glEndList();

}

glNewList(CONE, GL_COMPILE);

{

glutSolidCone(10, (NUM_DISKS + 1) * DISK_HEIGHT, 20, 20);

}

glEndList();

}

void

mpop(void)

{

move_node *temp = moves.head;

moves.head = moves.head->next;

free(temp);

moves.depth--;

}

void

mpush(int t, int f)

{

move_node *n = (move_node *) malloc(sizeof(move_node));

if (!n) {

fprintf(stderr, "Out of memory!\n");

exit(-1);

}

n->t = t;

n->f = f;

n->next = NULL;

n->prev = moves.tail;

if (moves.tail)

moves.tail->next = n;

moves.tail = n;

if (!moves.head)

moves.head = moves.tail;

moves.depth++;

}

/* ARGSUSED1 */

void

keyboard(unsigned char key, int x, int y)

{

switch (key) {

case 27: /* ESC */

case 'q':

case 'Q':

exit(0);

}

}

void

update(void)

{

glutPostRedisplay();

}

void

DrawPost(int xcenter)

{

glPushMatrix();

{

glTranslatef(xcenter, 0, 0);

glRotatef(90, -1, 0, 0);

glCallList(CONE);

} glPopMatrix();

}

void

DrawPosts(void)

{

glColor3fv(poleColor);

glLineWidth(10);

glMaterialfv(GL_FRONT, GL_DIFFUSE, poleColor);

DrawPost(WIDTH / 4);

DrawPost(2 * WIDTH / 4);

DrawPost(3 * WIDTH / 4);

}

void

DrawDisk(int xcenter, int ycenter, int size)

{

glPushMatrix();

{

glTranslatef(xcenter, ycenter, 0);

glRotatef(90, 1, 0, 0);

glCallList(size);

} glPopMatrix();

}

void

DrawDooDads(void)

{

int i;

stack_node *temp;

int xcenter, ycenter;

glColor3fv(diskColor);

glMaterialfv(GL_FRONT, GL_DIFFUSE, diskColor);

for (i = 1; i <= 3; i++) {

xcenter = i * WIDTH / 4;

for (temp = poles[i].head, ycenter = DISK_HEIGHT * poles[i].depth - DISK_HEIGHT / 2; temp; temp = temp->next, ycenter -= DISK_HEIGHT) {

DrawDisk(xcenter, ycenter, temp->size);

}

}

}

#define MOVE(t,f) mpush((t),(f))

static void

mov(int n, int f, int t)

{

int o;

if (n == 1) {

MOVE(t, f);

return;

}

o = other(f, t);

mov(n - 1, f, o);

mov(1, f, t);

mov(n - 1, o, t);

}

GLfloat wallcolor[] =

{0, .3, 1, 1};

void

DrawWall(void)

{

int i;

int j;

glColor3fv(wallcolor);

for (i = 0; i < WIDTH; i += 10) {

for (j = 0; j < HEIGHT; j += 10) {

glBegin(GL_POLYGON);

{

glNormal3f(0, 0, 1);

glVertex3f(i + 10, j, wallz);

glVertex3f(i + 10, j + 10, wallz);

glVertex3f(i, j + 10, wallz);

glVertex3f(i, j, wallz);

}

glEnd();

}

}

}

void

draw(void)

{

int t, f;

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

if (back_wall) {

glMaterialfv(GL_FRONT, GL_DIFFUSE, wallcolor);

DrawWall();

}

glPushMatrix();

{

glTranslatef(WIDTH / 2, HEIGHT / 2, 0);

glRotatef(xlangle, 0, 1, 0);

glRotatef(ylangle, 1, 0, 0);

glTranslatef(-WIDTH / 2, -HEIGHT / 2, 0);

glLightfv(GL_LIGHT0, GL_POSITION, lightZeroPosition);

}

glPopMatrix();

glPushMatrix();

{

glTranslatef(WIDTH / 2, HEIGHT / 2, 0);

glRotatef(xangle, 0, 1, 0);

glRotatef(yangle, 1, 0, 0);

glTranslatef(-WIDTH / 2, -HEIGHT / 2, 0);

DrawPosts();

DrawDooDads();

}

glPopMatrix();

if (motion && moves.depth) {

t = moves.head->t;

f = moves.head->f;

push(t, pop(f));

mpop();

}

glutSwapBuffers();

}

void

hanoi_menu(int value)

{

switch (value) {

case HANOI_SOLVE:

motion = !motion;

if(motion) {

glutIdleFunc(update);

} else {

glutIdleFunc(NULL);

}

break;

case HANOI_LIGHTING:

if (glIsEnabled(GL_LIGHTING))

glDisable(GL_LIGHTING);

else

glEnable(GL_LIGHTING);

break;

case HANOI_WALL:

back_wall = !back_wall;

break;

case HANOI_FOG:

if (glIsEnabled(GL_FOG))

glDisable(GL_FOG);

else {

glEnable(GL_FOG);

glFogi(GL_FOG_MODE, GL_EXP);

glFogf(GL_FOG_DENSITY, .01);

}

break;

case HANOI_QUIT:

exit(0);

break;

}

glutPostRedisplay();

}

int oldx, oldy;

GLboolean leftb = GL_FALSE, middleb = GL_FALSE;

void

hanoi_mouse(int button, int state, int x, int y)

{

if (button == GLUT_LEFT_BUTTON) {

oldx = x;

oldy = y;

if (state == GLUT_DOWN)

leftb = GL_TRUE;

else

leftb = GL_FALSE;

}

if (button == GLUT_MIDDLE_BUTTON) {

oldx = x;

oldy = y;

if (state == GLUT_DOWN)

middleb = GL_TRUE;

else

middleb = GL_FALSE;

}

}

void

hanoi_visibility(int state)

{

if (state == GLUT_VISIBLE && motion) {

glutIdleFunc(update);

} else {

glutIdleFunc(NULL);

}

}

void

hanoi_motion(int x, int y)

{

if (leftb) {

xangle -= (x - oldx);

yangle -= (y - oldy);

}

if (middleb) {

xlangle -= (x - oldx);

ylangle -= (y - oldy);

}

oldx = x;

oldy = y;

glutPostRedisplay();

}

int

main(int argc, char *argv[])

{

int i;

glutInit(&argc, argv);

for(i=1; i<argc; i++) {

if(!strcmp("-n", argv[i])) {

i++;

if(i >= argc) {

printf("hanoi: number after -n is required\n");

exit(1);

}

NUM_DISKS = atoi(argv[i]);

}

}

glutInitWindowSize(WIDTH, HEIGHT);

glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);

glutCreateWindow("Hanoi");

glutDisplayFunc(draw);

glutKeyboardFunc(keyboard);

glViewport(0, 0, WIDTH, HEIGHT);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho(0, WIDTH, 0, HEIGHT, -10000, 10000);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glClearColor(0, 0, 0, 0);

glClearDepth(1.0);

glEnable(GL_CULL_FACE);

glEnable(GL_DEPTH_TEST);

/* glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); */

glLightfv(GL_LIGHT1, GL_POSITION, lightOnePosition);

glLightfv(GL_LIGHT1, GL_DIFFUSE, lightOneColor);

glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 10);

glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, lightOneDirection);

glEnable(GL_LIGHT1);

glLightfv(GL_LIGHT2, GL_POSITION, lightTwoPosition);

glLightfv(GL_LIGHT2, GL_DIFFUSE, lightTwoColor);

/* glLightf(GL_LIGHT2,GL_LINEAR_ATTENUATION,.005); */

glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 10);

glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, lightTwoDirection);

glEnable(GL_LIGHT2);

glLightfv(GL_LIGHT0, GL_DIFFUSE, lightZeroColor);

glEnable(GL_LIGHT0);

glEnable(GL_LIGHTING);

glutMouseFunc(hanoi_mouse);

glutMotionFunc(hanoi_motion);

glutVisibilityFunc(hanoi_visibility);

glutCreateMenu(hanoi_menu);

glutAddMenuEntry("Solve", HANOI_SOLVE);

glutAddMenuEntry("Lighting", HANOI_LIGHTING);

glutAddMenuEntry("Back Wall", HANOI_WALL);

glutAddMenuEntry("Fog", HANOI_FOG);

glutAddMenuEntry("Quit", HANOI_QUIT);

glutAttachMenu(GLUT_RIGHT_BUTTON);

init();

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

push(1, NUM_DISKS - i);

mov(NUM_DISKS, 1, 3);

glutMainLoop();

return 0; /* ANSI C requires main to return int. */

}

What is the difference between nonadaptive and adaptive routing algorithms?

  1. Adaptive Routing Algorithm: These algorithms change their routing decisions to reflect changes in the topology and in traffic as well. These get their routing information from adjacent routers or from all routers. The optimization parameters are the distance, number of hops and estimated transit time. This can be further classified as follows:
    1. Centralized: In this type some central node in the network gets entire information about the network topology, about the traffic and about other nodes. This then transmits this information to the respective routers. The advantage of this is that only one node is required to keep the information. The disadvantage is that if the central node goes down the entire network is down, i.e. single point of failure.
    2. Isolated: In this method the node decides the routing without seeking information from other nodes. The sending node does not know about the status of a particular link. The disadvantage is that the packet may be send through a congested route resulting in a delay. Some examples of this type of algorithm for routing are:
  • Hot Potato: When a packet comes to a node, it tries to get rid of it as fast as it can, by putting it on the shortest output queue without regard to where that link leads. A variation of this algorithm is to combine static routing with the hot potato algorithm. When a packet arrives, the routing algorithm takes into account both the static weights of the links and the queue lengths.
  • Backward Learning: In this method the routing tables at each node gets modified by information from the incoming packets. One way to implement backward learning is to include the identity of the source node in each packet, together with a hop counter that is incremented on each hop. When a node receives a packet in a particular line, it notes down the number of hops it has taken to reach it from the source node. If the previous value of hop count stored in the node is better than the current one then nothing is done but if the current value is better then the value is updated for future use. The problem with this is that when the best route goes down then it cannot recall the second best route to a particular node. Hence all the nodes have to forget the stored informations periodically and start all over again.
Distributed: In this the node receives information from its neighbouring nodes and then takes the decision about which way to send the packet. The disadvantage is that if in between the the interval it receives information and sends the paket something changes then the packet may be delayed. Non-Adaptive Routing Algorithm: These algorithms do not base their routing decisions on measurements and estimates of the current traffic and topology. Instead the route to be taken in going from one node to the other is computed in advance, off-line, and downloaded to the routers when the network is booted. This is also known as static routing. This can be further classified as:
  1. Flooding: Flooding adapts the technique in which every incoming packet is sent on every outgoing line except the one on which it arrived. One problem with this method is that packets may go in a loop. As a result of this a node may receive several copies of a particular packet which is undesirable. Some techniques adapted to overcome these problems are as follows:
  • Sequence Numbers: Every packet is given a sequence number. When a node receives the packet it sees its source address and sequence number. If the node finds that it has sent the same packet earlier then it will not transmit the packet and will just discard it.
  • Hop Count: Every packet has a hop count associated with it. This is decremented(or incremented) by one by each node which sees it. When the hop count becomes zero(or a maximum possible value) the packet is dropped.
  • Spanning Tree: The packet is sent only on those links that lead to the destination by constructing a spanning tree routed at the source. This avoids loops in transmission but is possible only when all the intermediate nodes have knowledge of the network topology.

Flooding is not practical for general kinds of applications. But in cases where high degree of robustness is desired such as in military applications, flooding is of great help.

  1. Random Walk: In this method a packet is sent by the node to one of its neighbours randomly. This algorithm is highly robust. When the network is highly interconnected, this algorithm has the property of making excellent use of alternative routes. It is usually implemented by sending the packet onto the least queued link.

How do I write a program that inputs the length of two pieces of fabric in feet and inches as whole numbers and prints the total?

#include <stdio.h>

int main (void) {

unsigned f1, i1, f2, i2;

scanf ("Enter the 1st length in feet and inches: %u%u", f1, i1);

scanf ("Enter the 2nd length in feet and inches: %u%u", f2, i2);

unsigned inches = i1 + i2 + (12 * (f1 + f2)); // sum the inches (convert feet to inches)

unsigned feet = inches / 12; // convert inches to feet

inches %= 12; // determine the remaining inches

printf ("The total length is %u feet %u inches.\n", feet, inches);

return 0;

}