Hewlett Packard Interview Questions
- 1of 1 vote
AnswersThere are 3 threads. 1 is producer thread. 2 consumer threads. There is 1 buffer. Producer writes to the buffer. Consumers consume from buffer. How to synchronise between them so that consumers consume from buffer one after another, that is, the number of tokens that consumer thread1 consumes is same as number of tokens consumer thread2 consumes. Answer in c,linux
- mohapatrasandeep60 August 08, 2018 in India| Report Duplicate | Flag | PURGE
Hewlett Packard SDE-2 - 0of 0 votes
AnswersWe have 52 week price list for a stock S. Suppose that during this period, we want to buy 100 stocks of S and sell all of them at a later day (within the 52 week window). We want to know when should we have bought and sold in order to make maximum profit. (If there is no profit making scenario, then it should be reported).
- sunny.1rn12cs113 February 22, 2017 in India
Example, for a small 4 week window: P1 = 14, P2 = 6, P3 = 7, P4 = 11 Then the output should be "Buy on 2 and sell on 4". Short selling is not allowed.
How can you best classify the type of the algorithm? (Greedy or Divide & Conquer or Dynamic Programming, etc..)| Report Duplicate | Flag | PURGE
Hewlett Packard Developer Program Engineer - 0of 0 votes
AnswersGiven a list of stocks with their respective market capitalizations. The stock’s market cap are updated every minute based on its trading in the market. I have a strategy that wants a list of top 10 highest capped stocks in the market. This query can happen multiple times during the day.
- sunny.1rn12cs113 February 22, 2017 in India
Question: What would be the most appropriate data structure that can be used to efficiently implement the list of stocks? Discuss pros/cons of various data structures. Please briefly explain your answer.| Report Duplicate | Flag | PURGE
Hewlett Packard Developer Program Engineer - -2of 2 votes
AnswersInput
- mail.smohanty February 18, 2016 in India
2 5
2000
5000
Output
1000
Question: A real estate company plans to open relief distribution in few cities of a state.
The input in the first Line N(number of cities...2 as per example)
and M(Number of distribution center...5 as per example).
The next lines have the number of population in N(2) cities. (2000 and 5000) as per example.
Only people from a specific city can go to the distribution center of that city.
WAP to find the number of max people those can be accommodated in a distribution center.
The answer is 1000 in this case. As there are 7 distribution center.
First City having 2000 population will have 2 distribution center and second city having 5000 population will have 5 centers.
Therefore Max person that can be accommodated in a center is 1000.| Report Duplicate | Flag | PURGE
Hewlett Packard Dev Lead Algorithm - 0of 0 votes
Answersdesign a bit map of 16K bit
- capricornkmu October 17, 2015 in United States for Networking
get_bit, should get a free bit in this bit map
clear_bit, should clear a bit in this bit map| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer Algorithm - 1of 1 vote
Answerswrite a program to toggle certain bits in a integer.
- capricornkmu October 17, 2015 in United States for Networking
Eg.
Inputs : int a, int start bit, int num_of_bits
if a is say 11111010110100000
if start = 6
num_of_bits = 4
output should be (starting 6th bit from right, toggle 4 bits)
11111010001000000| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerswrite a program to count the 2 letter words in a sentence. Eg. "I am in love with New York" should return 2 (am and in).
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answersdesign routing table using trie
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer Network - 0of 0 votes
Answerwhat are the advantages of IPV6 over IPV4 other than the scale advantage ?
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer Network - 0of 0 votes
Answerwrite a program to find the number when a string is transformed to a palindrome, you can go from higher alphabet to lower alphabet and not the other way:
- capricornkmu October 17, 2015 in United States for Networking
Example:
to convert "abc" to palindrome, 'c' should be changed to 'a'. output should be 2 ('c' - 'a').| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answersfind bugs in the below program:
- capricornkmu October 17, 2015 in United States for Networking
void fn() {
int *i;
i = (int *) malloc (sizeof(int));
return;
}| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerwrite a program to merge 2 linked list
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answersdefine how packet reaches from one host to another host. Eg. in topology "host1 - router A - router B - host2" what happens in different layers
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer Network - 0of 0 votes
Answerswrite a program to delete the given node in a BST
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerwrite to program to find the set bits in an integer
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answershow traceroute works
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer Network - 0of 0 votes
Answershow would you calculate path mtu
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer Network - 0of 0 votes
Answerwrite a function to copy string. You are free to decide function parameters. But once you wrote the function, you need to specifically explain below points
- Sach July 20, 2015 in India
- Function parameters
- What are assumptions (For ex. Destination string should have sufficient memory allocated in advance. means function is not going to allocate memory for destination string)
- Limitation of your function
- Find bugs in your code.| Report Duplicate | Flag | PURGE
Hewlett Packard Tech Lead C - 0of 0 votes
AnswersThere is Ticketing vending machine which accepts Rs.1, Rs.2 and Rs. 5 coins. There is Rs. 5 Ticket. System will reject all invalid coins for ex. Rs 0.50, Rs. 0.25, Rs 10.
- Sach July 20, 2015 in India
System will not return any money or ticket if coin is invalid.| Report Duplicate | Flag | PURGE
Hewlett Packard Tech Lead Software Design - 0of 0 votes
AnswersDesign a your own Youtube. Which has feature like play, pause, resume, stop. Note that,
- Sach July 20, 2015 in India
- multiple users can be access multiple videos.
- Mutiple users can access same video at same time or different time.
- Need to tackle performance bottoleneck.| Report Duplicate | Flag | PURGE
Hewlett Packard Tech Lead Software Design - 0of 0 votes
AnswerI wanted to know if someone knows how to solve this algorithm in C#!!!
- andrew.coleman330 January 24, 2014 in United States for Andrew
I do not know this programming language that well and need it converted, you do not have to solve the algorithm but it would help if you can!
// You are free to implement the solution in C, C++ or C#.
// You are given a set of numbers stored in your own implementation of queue
// and another set of numbers stored in your own implementation of stack.
// The goal is to calculate the sum of those two sets of values.
// NOTE: You must implement your own Queue and Stack.
//
// Inputs:
// num1 = 123456
// num2 = 654321
// Output:
// result = 777777
#include <stdio.h>
#include <tchar.h>
//yourQueue implementation
//yourStack implementation
// Please use either String or char*
char *yourAdd (yourQueue *num1, yourStack *num2)
{
char *result = 0;
// Your code.
return result;
}
void main(int argc, _TCHAR* argv[])
{
yourQueue *num1; //should only be able to push 0-9. num1->push(10) is invalid
num1->push(1);
num1->push(2);
num1->push(3);
num1->push(4);
num1->push(5);
num1->push(6);
yourStack *num2; //should only be able to push 0-9. num2->push(10) is invalid
num2->push(1);
num2->push(2);
num2->push(3);
num2->push(4);
num2->push(5);
num2->push(6);
char *result = yourAdd(num1, num2);
printf("result: %s\n", result);
}| Report Duplicate | Flag | PURGE
Hewlett Packard Applications Developer Algorithm - -2of 2 votes
Answersclass NoName { children = new Hashtable() name = "" boolean hasChild(child: string) { return this.children.hasKey(child) } NoName addChild(child: string) { var childnode = new NoName() childnode.name = child this.children[child] = childnode return childnode } NoName getNode(child: string) { if this.hasChild(child) return this.children[child] else return this.addChild(child) } void addList(input: string) { var currentNode = this.getNode(input[0]) input = input.SubString(1, input.Length ? 1) if (input.Length < 1) currentNode.getNode("") else currentNode.addList(input) } string scan() { if (this.children.Values.Length == 0) return this.name if (this.children.Values.Length == 1) return this.name + this.children.Values[0].scan() var temp = new Array() foreach(child in this.children.Values) temp.Add(child.scan()) return this.name + "{" + temp.Sorted().JoinArray(",") + "}" } } var x = new NoName() x.addList(’/home/user/foo’) x.addList(’/home/user/bar’) x.addList(’/home/user/baz/one’) x.addList(’/home/user/baz/two’) print x.scan()
Is there anyone can help me translate these code to java or tell me the result ,I will really appreciate it.Thanks
- miller9977 January 10, 2014 in United States| Report Duplicate | Flag | PURGE
Hewlett Packard Java Developer Coding - -1of 1 vote
Answerswhat is memory leak ?
- gauravsharma29 May 12, 2012 in India| Report Duplicate | Flag | PURGE
Hewlett Packard Consultant Linux Kernel - -2of 2 votes
Answerswhich process / directory is responsible for the kernel is decompresed during boot up ?
- gauravsharma29 May 12, 2012 in India| Report Duplicate | Flag | PURGE
Hewlett Packard Consultant Linux Kernel - 1of 1 vote
Answersgiven a pid, how will you distinguish if it is a process or a thread ?
- gauravsharma29 May 12, 2012 in India| Report Duplicate | Flag | PURGE
Hewlett Packard Consultant Linux Kernel - 0of 0 votes
Answersint a[10]; a[-1] = 20;
where is 20 stored?
- Varun November 22, 2011 in India
I said this won't compile in C under normal circumstances, he agreed, and then said let's assume C allows this, what happens?? I said maybe then previous local variable of the function will get overwritten with this value.?? Nay insights?| Report Duplicate | Flag | PURGE
Hewlett Packard C - 0of 0 votes
Answerschar *p=NULL; p = (char *) malloc(10); p++; free(p)'
What happens, is there a leak?? are 10 bytes freed??
- Varun November 22, 2011 in India
I answered yes.| Report Duplicate | Flag | PURGE
Hewlett Packard C - 0of 0 votes
AnswersAn array having 100 elements have numbers from 1 to 99 randomly out of which any one number is repeated. I was asked to find repeated number in min time nd space complexity.
- hasinamjanu September 18, 2011 in India| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer - 0of 0 votes
AnswersVoid xyz(char a[10])
- Anonymous August 18, 2011
{
int i;
i=sizeof(a);
printf("%d",i);
}....its o/p is 2..wats d logic behind it..| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer - 0of 0 votes
Answers# define swap(a,b) temp=a; a=b; b=temp;
- Anonymous August 18, 2011
main( )
{
int i, j, temp;
i=5;
j=10;
temp=0;
if( i > j)
swap( i, j );
printf( "%d %d %d", i, j, temp);
}....its o/p on turbo c is 10 0 0..can any 1 explain the logic| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer