|
Yes. My finger got going a little too fast. Sorry.
Thank you Mark.
|
|
|
|
|
Hi,
I have a simple dialog that has a list control which displays a history of commands entered into the system.
Let's say I want to select the last argument from a command and copy and paste it somewhere, I just can't do that in a list control since it let me select the whole line only.
I tried using rich edit, but it has no notion of AddString which just adds text as we go.
Is there any control out there to solve this problem before I sub class Rich Edit ?????
Thanks.
|
|
|
|
|
I have No idea of what you wanty to achieve, other than to try and pick an individual piece of test out of a line in a control of some kind.You must be using something like a List or Tree Control, and you are probably trying to achieve an effect you have seen in some microsoft products. Do not forget, Microsoft has the luxurary of being able to throw say 500 writers at a problem, and sort it by the weekend, and also provide these writers with details of proven but not yet released features. Subclassing will probably work, but is a lot of work on your end, and may not mesh in with future microsoft code releases.
Why not try to be safe, and do as follows:-:
When you pick the line, bring up a Dialog Box with the entry in it in a readonly Edit box, Allow the user to pick a section of text, and work from there. You still will have to go thru the pallaver of validating the entry, etc, but at least you have your (several)problems isolated.
regards
LateNightsInNewry
|
|
|
|
|
Shay Harel wrote: Let's say I want to select the last argument from a command and copy and paste it somewhere, I just can't do that in a list control since it let me select the whole line only.
Of course that is what it's made for.
What about a simple multiline edit control with. Which is more handy than a list control.
There are applications that do that. Make this edit box a readonly one. After every command you can add new line.
This will help the user in selecting any line or any word or any character.
|
|
|
|
|
Data Structures
1. Which case you will use an array / Linked list?
2. Find the second maximum in an array? (Fastest way / better methodology)
3. How many comparisons you need to find second maximum?
4. How does a Binary search work?
5. How will you merge these two arrays? Write the program
Array: A 1 18 22 43
Array: B 3 4 6 20 34 46 55
Output Array: C 1 3 4 6 18 20 22 34 43 46 55
6. How do u create Hashtable in C?
7. What is hash collision?
8. What is the output of the following c program
#define calc(x) { 2*x}
a=2;
b=3;
printf calc(a+b);
printf calc(b+a);
9. Algo to find the 2nd max value in an array.
10. What is the difference between signed int and unsigned int?
11. Consider a singular link list with ‘N’ elements. One of the nodes doesn’t point to the next consecutive node instead it points to some other node in the beginning, thus leading into an infinite loop. How will you detect that there was an infinite loop and find the node that lead to the infinite loop.
12. Consider two stacks; Stack A and Stack B. Implement a Queue using these 2 stacks. (Need to implement Push & Pull)
13. Under what circumstances can one delete an element from a singly linked list in constant time?
14. Given a singly linked list, determine whether it contains a loop or not.
15. Given a singly linked list, print out its contents in reverse order. Can you do it without using any extra space? ANS. Start reversing the list. Do this again, printing the contents.
16. Given a binary tree with nodes, print out the values in pre-order/in-order/post-order without using any extra space.
17. Reverse a singly linked list recursively. The function prototype is node * reverse (node *) ;
18. Given a singly linked list, find the middle of the list.
HINT. Use the single and double pointer jumping. Maintain two pointers, initially pointing to the head. Advance one of them one node at a time. And the other one, two nodes at a time. When the double reaches the end, the single is in the middle. This is not asymptotically faster but seems to take less steps than going through the list twice.
19. Given a rectangular (cuboidal for the puritans) cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife ?
20. You're given an array containing both positive and negative integers and required to find the sub-array with the largest sum (O(N) a la KBL). Write a routine in C for the above.
21. Given an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others
22. Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2) without making use of any floating point computations at all. [ This one had me stuck for quite some time and I first gave a solution that did have floating point computations
23. Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].
24. Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]
25. Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.
26. How many points are there on the globe where by walking one mile south, one mile east and one mile north you reach the place where you started.
27. Give a very good method to count the number of ones in a "n" (e.g. 32) bit number.
28. What are the different ways to implement a condition where the value of x can be either a 0 or a 1. Apparently the if then else solution has a jump when written out in assembly. if (x == 0) y=a else y=b There is a logical, arithmetic and a data structure solution to the above problem.
29. In a X's and 0's game (i.e. TIC TAC TOE) if you write a program for this give a fast way to generate the moves by the computer. I mean this should be the fastest way possible.
The answer is that you need to store all possible configurations of the board and the move that is associated with that. Then it boils down to just accessing the right element and getting the corresponding move for it. Do some analysis and do some more optimization in storage since otherwise it becomes infeasible to get the required storage in a DOS machine.
30. I was given two lines of assembly code which found the absolute value of a number stored in two's complement form. I had to recognize what the code was doing. Pretty simple if you know some assembly and some fundaes on number representation.
31. Give a fast way to multiply a number by 7.
32. How would go about finding out where to find a book in a library. (You don't know how exactly the books are organized beforehand).
33. First some definitions for this problem: a) An ASCII character is one byte long and the most significant bit in the byte is always '0'. b) A Kanji character is two bytes long. The only characteristic of a Kanji character is that in its first byte the most significant bit is '1'.
Now you are given an array of a characters (both ASCII and Kanji) and, an index into the array. The index points to the start of some character. Now you need to write a function to do a backspace (i.e. delete the character before the given index).
34. Delete an element from a doubly linked list.
35. Write a function to find the depth of a binary tree.
36. Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
37. Assuming that locks are the only reason due to which deadlocks can occur in a system. What would be a foolproof method of avoiding deadlocks in the system.
38. Reverse a linked list.
39. Write a small lexical analyzer - interviewer gave tokens. expressions like "a*b" etc.
40. Besides communication cost, what is the other source of inefficiency in RPC? (answer : context switches, excessive buffer copying). How can you optimize the communication? (ans : communicate through shared memory on same machine, bypassing the kernel _ A Univ. of Wash. thesis)
41. Write a routine that prints out a 2-D array in spiral order!
42. How is the readers-writers problem solved? - using semaphores/ada .. etc.
43. Ways of optimizing symbol table storage in compilers.
44. A walk-through through the symbol table functions, lookup() implementation etc. - The interviewer was on the Microsoft C team.
45. Write an efficient algorithm and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.
46. Given an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).
47. Given an array of characters. How would you reverse it. ? How would you reverse it without using indexing in the array.
48. Given a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - solutions given in the C lib -typec.h)
49. Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).
50. Given an array of integers, find the contiguous sub-array with the largest sum.
51. Given an array of length N containing integers between 1 and N, determine if it contains any duplicates.
52. Sort an array of size n containing integers between 1 and K, given a temporary scratch integer array of size K.
53. An array of size k contains integers between 1 and n. You are given an additional scratch array of size n. Compress the original array by removing duplicates in it. What if k << n?
54. An array of integers. The sum of the array is known not to overflow an integer. Compute the sum. What if we know that integers are in 2's complement form?
55. An array of characters. Reverse the order of words in it.
56. An array of integers of size n. Generate a random permutation of the array, given a function rand_n() that returns an integer between 1 and n, both inclusive, with equal probability. What is the expected time of your algorithm?
57. An array of pointers to (very long) strings. Find pointers to the (lexicographically) smallest and largest strings.
58. Write a program to remove duplicates from a sorted array.
59. C++ ( what is virtual function ? what happens if an error occurs in constructor or destructor. Discussion on error handling, templates, unique features of C++. What is different in C++, ( compare with unix).
60. Given a list of numbers ( fixed list) Now given any other list, how can you efficiently find out if there is any element in the second list that is an element of the first list (fixed list).
61. Print an integer using only putchar. Try doing it without using extra storage.
62. Write C code for (a) deleting an element from a linked list (b) traversing a linked list
63. What are various problems unique to distributed databases
64. Declare a void pointer ANS. void *ptr;
65. Make the pointer aligned to a 4 byte boundary in a efficient manner ANS. Assign the pointer to a long number and the number with 11...1100 add 4 to the number
66. What is a balanced tree
67. A real life problem - A square picture is cut into 16 squares and they are shuffled. Write a program to rearrange the 16 squares to get the original big square.
68. int *a;
char *c;
*(a) = 20;
*c = *a;
printf("%c",*c);
what is the output?
69. Write a program to find whether a given m/c is big-endian or little-endian!
General Concepts
1. What is TCP?
2. What is HTTP?
3. How does HTTP use TCP? (Or) In which Layer does it sit?
4. Project life cycle
5. Difference between GET and POST?
6. What is a cookie? How do they work?
Database
1. What is an index (SQL Server)?
2. When will you use Clustered Index and Non-clustered index? Provide example of each one.
3. Are you aware of Stored Procedure?
4. What is the difference between inner join and outer join?
5. How do u trace and monitor performance of queries in SQL server?
6. What is normalization? Types of normalization.
7. Consider this scenario; when a normal select statement is executed on a table it is fast. But when two tables are joined on a certain condition, the same query takes a long time to execute. What would you do to solve this issue?
8. What are Stored Procedures? How does it work? Advantages and disadvantages of the stored procedures.
Testing
1. Tradeoff between time spent in testing a product and getting into the market first.
2. What to test for given that there isn't enough time to test everything you want to.
5. Design test cases for moblies set/cell phone (or) how do u go abt testing mobile phone?
6. Write a program to find whether a triangle is equilateral or isoceless or some other triangle and also write test cases for them (Input is three sides of a triangle a,b,c
7. write a test case with input data so that it can be an invalid triangle( sum of two sides should be greater than third side etc)
8. How do u test and know abt memory leakage? How do u write a script to see the impact of memory leakage because in some cases the leakage can be small which u cant notice?
9. When you are not getting a page/resource from server, what is your action for that? whether u login to server and see that page is there or not? How come u know that the prob is from browser to web server or from web server to DB server?
10. What is the metrics u look at when defining performance requirements?
11. When you feel a particular requirement is to be changed after the SRS is frozen, how do u go abt it i.e will u inform PM of the same or else u simply keep quiet?
12. What is challenging QA or development? and why?
13. what is the difference between performance and stress testing?
16. Write a function that counts the number of primes in the range [1-N]. Write the test cases for this function.
17. Given a MAKEFILE (yeah a makefile), design the data structure that a parser would create and then write code that iterates over that data structure executing commands if needed.
18. Write a function that inserts an integer into a linked list in ascending order. Write the test cases for this function.
19. Test the save dialog in Notepad.
20. Write the InStr function. Write the test cases for this function.
21. Write a function that will return the number of days in a month (no using System.DateTime).
22. Write the test cases for a vending machine.
|
|
|
|
|
|
Is this an attempt to the 2006 version of the 'Erlangen' Program??
Are there any mathematicians left amongst you to remember about that one?
The 4 Colour problem, Fermats' theorem, and several bakers dozens more!
This was posted either by an idiot trying to pull of an exam scam or something like it, or else by one of the elder statesmen of computing.
I suspect the former, but offer to eat humble pie for the next two hours if it turns out to be the latter.
regards
LateNightsInNewry
|
|
|
|
|
Lets forget the smart replies about doing homework. I think you stole the whole goddam exam paper!
|
|
|
|
|
AryaSoft wrote: 7. What is hash collision?
Oh wait, I remember this one from college.
Something to do with two hash pipes passed different directions and the ensuing chaos...
|
|
|
|
|
This is the best one I've ever seen! Legendary!
Damn, I've got alot of work to do if I'm going to respond to this one.
Cheers,
Mark
|
|
|
|
|
Mark Salsbery wrote: Legendary!
Software development is a race between the programmers building bigger and better software and the universe building bigger and better idiots, so far the universe is winning.
led mike
|
|
|
|
|
Do you really think that someone here has soo much time to loose ?
|
|
|
|
|
37 - Don't use locks!
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Mark obviously does
|
|
|
|
|
This topic is not about answering a question ... instead it is about discussing various ways in which any of this questions can be tackled! And guys for your info its not an Home Work Assignment ... They are just some topics I found!
And btw Nobody needs to discuss about all ... if you CAN dare to discuss any one of them, thats more than enough
|
|
|
|
|
Is there an easy way to programatically detect overlapping child windows? I have a nearly flicker free gui, I say nearly because when windows are obscuring each other they like to fight about who should appear on the screen. I was hoping to find a valid clipping region in the DC passed to WM_ERASEBKGND, but no such luck, even with the WS_CLIPSIBLINGS bit set.
Also, could somebody please help me to understand the Z order of windows. Am I right in thinking that all children of the same window would have the same Z order? Or is there a definite sequence?
|
|
|
|
|
waldermort wrote: they like to fight about who should appear on the screen
Use the WS_SURRENDER style.
waldermort wrote: Or is there a definite sequence?
No it is random.
Sorry the thread below put me in a mood.
led mike
|
|
|
|
|
led mike wrote: Use the WS_SURRENDER style
g'damit, I was using the WS_WHITETOWEL style.
|
|
|
|
|
waldermort wrote: g'damit, I was using the WS_WHITETOWEL style
Rookie mistake
|
|
|
|
|
Check this article for how to avoid flickering by using the CMemDC object.
http://www.codeguru.com/Cpp/misc/misc/flickerfreedrawing/article.php/c389
For the Z order, each child of an MDI window has its own Z-order. To iterate through the Z-Order of each child window, you can use the following API:
CWnd::GetWindow() with GW_HWNDNEXT/GW_HWNDPREV or CWnd::GetNextWindow() and while iterating through the windows, you can identify their Z-order.
|
|
|
|
|
Shahzad Asif wrote: Check this article for how to avoid flickering by using the CMemDC object.
Thanks for the link, but double duffering is for the little kids who want the easy way out. I'm making a point in this project to not use any off screen drawing.
|
|
|
|
|
Well, depending on how many drawing operations you have, you might have to use double buffering techniques if you want it to be flicker free.
If you are going to clip child windows in the erase background handler, I suggest you create a region (CRgn) based on the child window rectangles, and use it as clipping mask. That way the parent handler will not erase the background of your child windows (why aren't you using WS_CLIPCHILDREN anyway?? - WS_CLIPSIBLINGS only affect sibling windows).
--
Torn from tomorrow's headlines
|
|
|
|
|
Joergen Sigvardsson wrote: I suggest you create a region (CRgn) based on the child window rectangles
Thats exactly what I am doing. Due to the nature of the various shapes of my windows, I cannot use the WS_CLIPCHILDREN style for two reasons. I find it to be a lot slower than my own techniques and unless SetWindowRgn() is called for each child, the clipping region is always rectangular.
Clipping the children from the parent is no problem. But clipping the siblings from each other is where I am having some trouble. Obviously the topmost child takes priority, but the underlaying child needs to have it's clipping region altered.
|
|
|
|
|
That's a nice approach
waldermort wrote: I find it to be a lot slower than my own techniques
My code doesn't work, but it's the fastest available
(Sorry, but that was really funny )
|
|
|
|
|
Given my (relatively) advanced years, I'm allowed to be a grumpy old man.
I'm now exercising that right (and I recognise that no right exists without responsibility, and it's part of that responsibility towards the usefulness of CP as a contributor via the forums that makes me act).
MFC is a set of foundation classes to make working with Win32 easier.
That's 'easier', not necessarily 'easy'. It helps tremendously if you can learn about the Win32 API itself while you are using MFC, because some day you will need to write something that there's no wrapper for.
Go and read Petzold, or actually read the MSDN documentation. At a push, step into some of the source of MFC. But do something that will actually advance your knowledge of the area you're working in.
If you're doing CS in college, pay more attention when your proposed assignments or homework are being discussed. If you don't want to do the work, you won't reap the reward (or if you do, it won't last past your first week in a new job).
If you're doing this for a living (which many of us here are), recognise that hey, we are all in the same boat here, and it pays to be polite, and help where you can. Unless I missed a memo somewhere, no one actually gets paid to help anyone else on here, so if you come across as insufferably rude, you won't get much help.
If I see "URGENT: PLEASE HELP", I tend to skip that. No point helping people who can't plan properly
Steve S
Developer for hire
|
|
|
|
|