SlideShare a Scribd company logo
1 of 7
MUM TEST

1. Write a function that accepts an array of non-negative integers and returns the second largest
integer in the array. Return -1 if there is no second largest. You may assume that the input array has
no negative values in it.



If you are programming in Java or C#, the signature of the function is

int f(int[ ] a)



If you are programming in C or C#, the signature of the function is

int f(int a[ ], int len) where len is the number of elements in a.

Examples:

if the input array is    return

{1, 2, 3, 4}               3

{{4, 1, 2, 3}}             3

{1, 1, 2, 2}              1

{1, 1}                   -1

{1}                      -1

{}                       -1



2. Write a function that takes an array of integers as an argument and returns a value based on the
sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and
let Y = the sum of the even numbers. The function should return X - Y



If you are using Java or C#, the signature of the function is:

int f(int[ ] a)

If you are using C or C++, the signature of the function is:

int f(int[ ] a, int len) where len is the number of elements in a.


1|Page
Examples

if input array is return

{1}                     1

{1, 2}                  -1

{1, 2, 3}               2

{1, 2, 3, 4}            -2

{3, 3, 4, 4}            -2

{3, 2, 3, 4}            0

{4, 1, 2, 3}            -2

{1, 1}                  2

{}                      0



3. Write a function that accepts a character array, a zero-based start position and a length. It should
return a character array containing containing length characters starting with the start character of
the input array. The function should do error checking on the start position and the length and return
null if the either value is not legal.



If you are programming in Java or C#, the function signature is:

char[ ] f(char[ ] a, int start, int len)



If you are programming in C or C++, the function signature is:

char * f(char a[ ], int start, int len, int lenA) where lenA is the number of elements in a.

Examples

if input parameters are               return

{'a', 'b', 'c'}, 0, 4                null

{'a', 'b', 'c'}, 0, 3              {'a', 'b', 'c'}

{'a', 'b', 'c'}, 0, 2                {'a', 'b'}

2|Page
{'a', 'b', 'c'}, 0, 1             {'a'}

{'a', 'b', 'c'}, 1, 3                  null

{'a', 'b', 'c'}, 1, 2             {'b', 'c'}

{'a', 'b', 'c'}, 1, 1             {'b'}

{'a', 'b', 'c'}, 2, 2             null

{'a', 'b', 'c'}, 2, 1             {'c'}

{'a', 'b', 'c'}, 3, 1             null

{'a', 'b', 'c'}, 1, 0             {}

{'a', 'b', 'c'}, -1, 2            null

{'a', 'b', 'c'}, -1, -2           null

{}, 0, 1                          null




                                          Answers
First answer
 public static void main()

 {

     a1(new int[]{1, 2, 3, 4});

     a1(new int[]{4, 1, 2, 3});

     a1(new int[]{1, 1, 2, 2});

     a1(new int[]{1, 1});

     a1(new int[]{1});

     a1(new int[]{});

 }




3|Page
static int a1(int[] a)

{

    int max1 = -1;

    int max2 = -1;



    for (int i=0; i<a.length; i++)

    {

        if (a[i] > max1)

        {

            max2 = max1;

            max1 = a[i];

        }

        else if (a[i] != max1 && a[i] > max2)

            max2 = a[i];

    }



    return max2;

}




Second answer

public static void main()

{

    a2(new int[] {1});

4|Page
a2(new int[] {1, 2});

    a2(new int[] {1, 2, 3});

    a2(new int[] {1, 2, 3, 4});

    a2(new int[] {3, 3, 4, 4});

    a2(new int[] {3, 2, 3, 4});

    a2(new int[] {4, 1, 2, 3});

    a2(new int[] {1, 1});

    a2(new int[] {});

}



static int a2(int[] a)

{

    int sumEven = 0;

    int sumOdd = 0;



    for (int i=0; i<a.length; i++)

    {

        if (a[i]%2 == 0)

         sumEven += a[i];

        else

         sumOdd += a[i];

    }



    return sumOdd - sumEven;

}



5|Page
Third answer

public static void main()

{

    a3(new char[]{'a', 'b', 'c'}, 0, 4);

    a3(new char[]{'a', 'b', 'c'}, 0, 3);

    a3(new char[]{'a', 'b', 'c'}, 0, 2);

    a3(new char[]{'a', 'b', 'c'}, 0, 1);

    a3(new char[]{'a', 'b', 'c'}, 1, 3);

    a3(new char[]{'a', 'b', 'c'}, 1, 2);

    a3(new char[]{'a', 'b', 'c'}, 1, 1);

    a3(new char[]{'a', 'b', 'c'}, 2, 2);

    a3(new char[]{'a', 'b', 'c'}, 2, 1);

    a3(new char[]{'a', 'b', 'c'}, 3, 1);

    a3(new char[]{'a', 'b', 'c'}, 1, 0);

    a3(new char[]{}, 0, 1);

    a3(new char[]{'a', 'b', 'c'}, -1, 2);

    a3(new char[]{'a', 'b', 'c'}, -1, -2);

}



static char[] a3(char[] a, int start, int length)

{

    if (length < 0 || start < 0 || start+length-1>=a.length)

    {


6|Page
return null;

    }



    char[] sub = new char[length];

    for (int i=start, j=0; j<length; i++, j++)

    {

        sub[j] = a[i];

    }



    return sub;

}




7|Page

More Related Content

What's hot

Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structureRumman Ansari
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solutionrohit kumar
 
Select All Record From Tools Menu On Find Receipts For Matching Form
Select All Record From Tools Menu On Find Receipts For Matching FormSelect All Record From Tools Menu On Find Receipts For Matching Form
Select All Record From Tools Menu On Find Receipts For Matching FormAhmed Elshayeb
 
Oracle SQL, PL/SQL best practices
Oracle SQL, PL/SQL best practicesOracle SQL, PL/SQL best practices
Oracle SQL, PL/SQL best practicesSmitha Padmanabhan
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Mario Fusco
 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsSreedhar Chowdam
 
New features of SQL in Firebird
New features of SQL in FirebirdNew features of SQL in Firebird
New features of SQL in FirebirdMind The Firebird
 
Boxing & unboxing
Boxing & unboxingBoxing & unboxing
Boxing & unboxingLarry Nung
 
Function in c program
Function in c programFunction in c program
Function in c programumesh patil
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
 
Legal Employer Details Query Oracle Fusion Cloud
Legal Employer Details Query Oracle Fusion CloudLegal Employer Details Query Oracle Fusion Cloud
Legal Employer Details Query Oracle Fusion CloudFeras Ahmad
 
Oracle Fusion Cloud Payroll Costing Query
Oracle Fusion Cloud Payroll Costing QueryOracle Fusion Cloud Payroll Costing Query
Oracle Fusion Cloud Payroll Costing QueryFeras Ahmad
 
DBI database Items Query Oracle Fusion Cloud
DBI database Items Query Oracle Fusion CloudDBI database Items Query Oracle Fusion Cloud
DBI database Items Query Oracle Fusion CloudFeras Ahmad
 
Deep Learning from scratch 3장 : neural network
Deep Learning from scratch 3장 : neural networkDeep Learning from scratch 3장 : neural network
Deep Learning from scratch 3장 : neural networkJinSooKim80
 
Chapter 1 : Balagurusamy_ Programming ANsI in C
Chapter 1  :  Balagurusamy_ Programming ANsI in C Chapter 1  :  Balagurusamy_ Programming ANsI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C BUBT
 

What's hot (20)

Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structure
 
Java String class
Java String classJava String class
Java String class
 
Let us c chapter 4 solution
Let us c chapter 4 solutionLet us c chapter 4 solution
Let us c chapter 4 solution
 
Java generics
Java genericsJava generics
Java generics
 
Select All Record From Tools Menu On Find Receipts For Matching Form
Select All Record From Tools Menu On Find Receipts For Matching FormSelect All Record From Tools Menu On Find Receipts For Matching Form
Select All Record From Tools Menu On Find Receipts For Matching Form
 
Oracle SQL, PL/SQL best practices
Oracle SQL, PL/SQL best practicesOracle SQL, PL/SQL best practices
Oracle SQL, PL/SQL best practices
 
Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...Laziness, trampolines, monoids and other functional amenities: this is not yo...
Laziness, trampolines, monoids and other functional amenities: this is not yo...
 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, Exceptions
 
New features of SQL in Firebird
New features of SQL in FirebirdNew features of SQL in Firebird
New features of SQL in Firebird
 
Boxing & unboxing
Boxing & unboxingBoxing & unboxing
Boxing & unboxing
 
Function in c program
Function in c programFunction in c program
Function in c program
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
Bubble in link list
Bubble in link listBubble in link list
Bubble in link list
 
Legal Employer Details Query Oracle Fusion Cloud
Legal Employer Details Query Oracle Fusion CloudLegal Employer Details Query Oracle Fusion Cloud
Legal Employer Details Query Oracle Fusion Cloud
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Good sql server interview_questions
Good sql server interview_questionsGood sql server interview_questions
Good sql server interview_questions
 
Oracle Fusion Cloud Payroll Costing Query
Oracle Fusion Cloud Payroll Costing QueryOracle Fusion Cloud Payroll Costing Query
Oracle Fusion Cloud Payroll Costing Query
 
DBI database Items Query Oracle Fusion Cloud
DBI database Items Query Oracle Fusion CloudDBI database Items Query Oracle Fusion Cloud
DBI database Items Query Oracle Fusion Cloud
 
Deep Learning from scratch 3장 : neural network
Deep Learning from scratch 3장 : neural networkDeep Learning from scratch 3장 : neural network
Deep Learning from scratch 3장 : neural network
 
Chapter 1 : Balagurusamy_ Programming ANsI in C
Chapter 1  :  Balagurusamy_ Programming ANsI in C Chapter 1  :  Balagurusamy_ Programming ANsI in C
Chapter 1 : Balagurusamy_ Programming ANsI in C
 

Viewers also liked

Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentalsOm Ganesh
 
Bai tap loi_giai_xac_suat_thong_ke_2733
Bai tap loi_giai_xac_suat_thong_ke_2733Bai tap loi_giai_xac_suat_thong_ke_2733
Bai tap loi_giai_xac_suat_thong_ke_2733behieuso1
 
Bài tập Xác suất thống kê
Bài tập Xác suất thống kêBài tập Xác suất thống kê
Bài tập Xác suất thống kêHọc Huỳnh Bá
 

Viewers also liked (6)

Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Data Structures (BE)
Data Structures (BE)Data Structures (BE)
Data Structures (BE)
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
Bai tap loi_giai_xac_suat_thong_ke_2733
Bai tap loi_giai_xac_suat_thong_ke_2733Bai tap loi_giai_xac_suat_thong_ke_2733
Bai tap loi_giai_xac_suat_thong_ke_2733
 
bai tap co loi giai xac suat thong ke
bai tap co loi giai xac suat thong kebai tap co loi giai xac suat thong ke
bai tap co loi giai xac suat thong ke
 
Bài tập Xác suất thống kê
Bài tập Xác suất thống kêBài tập Xác suất thống kê
Bài tập Xác suất thống kê
 

Similar to Maharishi University of Management (MSc Computer Science test questions)

131 Lab slides (all in one)
131 Lab slides (all in one)131 Lab slides (all in one)
131 Lab slides (all in one)Tak Lee
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guideThalaAjith33
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxrohinitalekar1
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework HelpC++ Homework Help
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2YOGESH SINGH
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsSunil Yadav
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functionsSwarup Boro
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updatedvrgokila
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfaroraopticals15
 
Computation of Semi-Magic Squares Generated by Serpentine Matrices
Computation of Semi-Magic Squares Generated by Serpentine MatricesComputation of Semi-Magic Squares Generated by Serpentine Matrices
Computation of Semi-Magic Squares Generated by Serpentine MatricesLossian Barbosa Bacelar Miranda
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programmingPrudhviVuda
 

Similar to Maharishi University of Management (MSc Computer Science test questions) (20)

131 Lab slides (all in one)
131 Lab slides (all in one)131 Lab slides (all in one)
131 Lab slides (all in one)
 
Virtusa questions placement preparation guide
Virtusa questions placement preparation guideVirtusa questions placement preparation guide
Virtusa questions placement preparation guide
 
Qno 3 (a)
Qno 3 (a)Qno 3 (a)
Qno 3 (a)
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
C++ Programming Homework Help
C++ Programming Homework HelpC++ Programming Homework Help
C++ Programming Homework Help
 
C Programming Unit-3
C Programming Unit-3C Programming Unit-3
C Programming Unit-3
 
VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2VIT351 Software Development VI Unit2
VIT351 Software Development VI Unit2
 
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm ProblemsLeet Code May Coding Challenge - DataStructure and Algorithm Problems
Leet Code May Coding Challenge - DataStructure and Algorithm Problems
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
 
Array&amp;string
Array&amp;stringArray&amp;string
Array&amp;string
 
Arrays
ArraysArrays
Arrays
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
 
Array
ArrayArray
Array
 
Unit 3 arrays and_string
Unit 3 arrays and_stringUnit 3 arrays and_string
Unit 3 arrays and_string
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
Array
ArrayArray
Array
 
Computation of Semi-Magic Squares Generated by Serpentine Matrices
Computation of Semi-Magic Squares Generated by Serpentine MatricesComputation of Semi-Magic Squares Generated by Serpentine Matrices
Computation of Semi-Magic Squares Generated by Serpentine Matrices
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 

Recently uploaded

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesShubhangi Sonawane
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Maharishi University of Management (MSc Computer Science test questions)

  • 1. MUM TEST 1. Write a function that accepts an array of non-negative integers and returns the second largest integer in the array. Return -1 if there is no second largest. You may assume that the input array has no negative values in it. If you are programming in Java or C#, the signature of the function is int f(int[ ] a) If you are programming in C or C#, the signature of the function is int f(int a[ ], int len) where len is the number of elements in a. Examples: if the input array is return {1, 2, 3, 4} 3 {{4, 1, 2, 3}} 3 {1, 1, 2, 2} 1 {1, 1} -1 {1} -1 {} -1 2. Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and let Y = the sum of the even numbers. The function should return X - Y If you are using Java or C#, the signature of the function is: int f(int[ ] a) If you are using C or C++, the signature of the function is: int f(int[ ] a, int len) where len is the number of elements in a. 1|Page
  • 2. Examples if input array is return {1} 1 {1, 2} -1 {1, 2, 3} 2 {1, 2, 3, 4} -2 {3, 3, 4, 4} -2 {3, 2, 3, 4} 0 {4, 1, 2, 3} -2 {1, 1} 2 {} 0 3. Write a function that accepts a character array, a zero-based start position and a length. It should return a character array containing containing length characters starting with the start character of the input array. The function should do error checking on the start position and the length and return null if the either value is not legal. If you are programming in Java or C#, the function signature is: char[ ] f(char[ ] a, int start, int len) If you are programming in C or C++, the function signature is: char * f(char a[ ], int start, int len, int lenA) where lenA is the number of elements in a. Examples if input parameters are return {'a', 'b', 'c'}, 0, 4 null {'a', 'b', 'c'}, 0, 3 {'a', 'b', 'c'} {'a', 'b', 'c'}, 0, 2 {'a', 'b'} 2|Page
  • 3. {'a', 'b', 'c'}, 0, 1 {'a'} {'a', 'b', 'c'}, 1, 3 null {'a', 'b', 'c'}, 1, 2 {'b', 'c'} {'a', 'b', 'c'}, 1, 1 {'b'} {'a', 'b', 'c'}, 2, 2 null {'a', 'b', 'c'}, 2, 1 {'c'} {'a', 'b', 'c'}, 3, 1 null {'a', 'b', 'c'}, 1, 0 {} {'a', 'b', 'c'}, -1, 2 null {'a', 'b', 'c'}, -1, -2 null {}, 0, 1 null Answers First answer public static void main() { a1(new int[]{1, 2, 3, 4}); a1(new int[]{4, 1, 2, 3}); a1(new int[]{1, 1, 2, 2}); a1(new int[]{1, 1}); a1(new int[]{1}); a1(new int[]{}); } 3|Page
  • 4. static int a1(int[] a) { int max1 = -1; int max2 = -1; for (int i=0; i<a.length; i++) { if (a[i] > max1) { max2 = max1; max1 = a[i]; } else if (a[i] != max1 && a[i] > max2) max2 = a[i]; } return max2; } Second answer public static void main() { a2(new int[] {1}); 4|Page
  • 5. a2(new int[] {1, 2}); a2(new int[] {1, 2, 3}); a2(new int[] {1, 2, 3, 4}); a2(new int[] {3, 3, 4, 4}); a2(new int[] {3, 2, 3, 4}); a2(new int[] {4, 1, 2, 3}); a2(new int[] {1, 1}); a2(new int[] {}); } static int a2(int[] a) { int sumEven = 0; int sumOdd = 0; for (int i=0; i<a.length; i++) { if (a[i]%2 == 0) sumEven += a[i]; else sumOdd += a[i]; } return sumOdd - sumEven; } 5|Page
  • 6. Third answer public static void main() { a3(new char[]{'a', 'b', 'c'}, 0, 4); a3(new char[]{'a', 'b', 'c'}, 0, 3); a3(new char[]{'a', 'b', 'c'}, 0, 2); a3(new char[]{'a', 'b', 'c'}, 0, 1); a3(new char[]{'a', 'b', 'c'}, 1, 3); a3(new char[]{'a', 'b', 'c'}, 1, 2); a3(new char[]{'a', 'b', 'c'}, 1, 1); a3(new char[]{'a', 'b', 'c'}, 2, 2); a3(new char[]{'a', 'b', 'c'}, 2, 1); a3(new char[]{'a', 'b', 'c'}, 3, 1); a3(new char[]{'a', 'b', 'c'}, 1, 0); a3(new char[]{}, 0, 1); a3(new char[]{'a', 'b', 'c'}, -1, 2); a3(new char[]{'a', 'b', 'c'}, -1, -2); } static char[] a3(char[] a, int start, int length) { if (length < 0 || start < 0 || start+length-1>=a.length) { 6|Page
  • 7. return null; } char[] sub = new char[length]; for (int i=start, j=0; j<length; i++, j++) { sub[j] = a[i]; } return sub; } 7|Page