Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Joanna Szczesniak: Q1. Write a function in C/C++ to determine if a string starts with a numeric value (0-9)
- (No function calls, no stl libraries)
- bool StartsWithNumeric(char* szString)
- {
- }
- Joanna Szczesniak: Q.2 Given an interger array of arbituary size, can you find a way to find duplicates values in it?
- (No function calls, no stl libraries)
- bool hasDuplicate( int* pnValues, int nSize)
- {
- }
- Joanna Szczesniak: Q3. Can you briefly describe what does the function(s) below perform?
- struct Snode {
- Snode* p1;
- Snode* p2;
- int nValue;
- };
- bool Test( int nValue, Snode* psRoot )
- {
- if ( NULL == psRoot ) {
- return false;
- }
- if ( psRoot->nValue > nValue ) {
- if ( NULL != psRoot->p1 ) {
- return Test( nValue, psRoot->p1 );
- }
- psRoot->p1 = new Snode;
- if ( NULL == psRoot->p1 ) {
- return false;
- }
- psRoot->p1->p1 = NULL;
- psRoot->p1->p2 = NULL;
- psRoot->p1->nValue = nValue;
- return true;
- }
- else {
- if ( NULL != psRoot->p2 ) {
- return Test( nValue, psRoot->p2 );
- }
- psRoot->p2 = new Snode;
- if ( NULL == psRoot->p2 ) {
- return false;
- }
- psRoot->p2->p1 = NULL;
- psRoot->p2->p2 = NULL;
- psRoot->p2->nValue = nValue;
- return true;
- }
- }
- Joanna Szczesniak: Q4. Given a C String, can you describe how to flip the word from
- “Hello” => “olleH”
- “Maintenance” => “ecnanetniaM”
- Joanna Szczesniak: Q5. If you do not have memory space to allocate any array and unable to use any function calls, how would you do it? Try to manipulate from the input string buffer.
- Joanna Szczesniak: Q6. Can you think of an algorithm that performs the below:
- “The Big Brown Fox” => “Fox Brown Big The”
- “How are you?” => “you? are How”
- Joanna Szczesniak: Q7. If you also do not have memory space to perform the above, how would you do it?
- Joanna Szczesniak: Q8. Here’s a hint, what happens when you use the sentence to be processed by the previous question’s function?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement