Software Engineering Interview Questions

Want to become an expert in cracking Software Engineering interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public Software Engineering Interview Questions Test.

To use our service for testing candidates, buy a pack of candidates.


1. Big O Notation

Software Engineering Complexity Public New

For the following pseudocode functions, choose the big O notation that accurately describes its worst-case complexity.

Easy 
5min
function Doubler(number : integer)
  integer i = 1
  loop (while i < number)
    i = i * 2
    Display(i)
  end loop
end function

function GetFirstElement(elements : array) : integer
  return elements[0]
end function

function DisplayPairsFromList(elements : array)
  integer i = 0
  integer size = elements->Count()
  loop (while i < size)
    integer j = 0
    loop (while j < size)
      Display(elements[i] + ", " + elements[j])
      j = j + 1
    end loop
    i = i + 1
  end loop
end function

function Recursive(number : integer) : integer
  if (number <= 1)
    return number

  return Recursive(number - 4) + Recursive(number - 2)
end function
   


2. Serialize Cart

Software Engineering OOP Public New

In a language that supports OOP paradigm, we have the following code that serializes the content of a shopping cart to JSON format:

class ShoppingCart
  private content : Dictionary<int, string> 

  public function serialize() : string
    return new JsonSerializer().serialize(content.clone())
  end function
end class

class JsonSerializer  
  public function serialize(value : Dictionary<int, string>) : string
    ' Code that serializes dictionary to JSON format and returns it as string
  end function
end class

A client now wants to have the possibility for allowing plugins to serialize the shopping cart content to their own formats (e.g., XML). Select lines of code that, together, would extend the code above to allow this extensibility.

(Select all acceptable answers.)

Easy 
5min
class JsonSerializer
Should be changed to:
class JsonSerializer inherits ISerializer
Add interface definition:
interface ISerializer
  public function serialize(Dictionary<int, string>) : string
end interface
Add Enum definition that will be extended as new plugins will be added (e.g., to add XML serialization):
enumeration SerializerType
  Json,
  Xml
end enumeration
Change ShoppingCart's serialize implementation to one like below (e.g., to add XML serialization):
public function serialize(serializer : SerializerType) : string
  if(serializer == SerializerType.Json)
    return new JsonSerializer().serialize(content.clone())
  else if(serializer == SerializerType.Xml)
    return new XmlSerializer().serialize(content.clone())
  else 
    throw Error("Not implemented error!");
  end if    
end function
Change ShoppingCart's serialize implementation to:
public function serialize(serializer : ISerializer) : string
  return serializer.serialize(content.clone())
end function
Change ShoppingCart's data member from:
private content : Dictionary<int, string>
to:
public content : Dictionary<int, string>
so that plugins can directly manipulate and save the shopping cart.
   


3. Stack vs Queue

Software Engineering Data structures Public New

Answer the questions below regarding correct usage of data structures.

Easy 
5min

Given an empty object stackOfNumbers of type Stack, review the sequence of function calls:

stackOfNumbers->Push(10)
stackOfNumbers->Push(12)
stackOfNumbers->Push(13)
stackOfNumbers->Peek()
stackOfNumbers->Push(8)
stackOfNumbers->Pop()
stackOfNumbers->Push(9)
stackOfNumbers->Peek()

If Pop() were called again, it would return:


Given an empty object queueOfNumbers of type Queue, review the sequence of function calls:

queueOfNumbers->Enqueue(10)
queueOfNumbers->Enqueue(12)
queueOfNumbers->Enqueue(13)
queueOfNumbers->Peek()
queueOfNumbers->Enqueue(8)
queueOfNumbers->Dequeue()
queueOfNumbers->Enqueue(9)
queueOfNumbers->Peek()

If Dequeue() were called again, it would return: 


In which one of these scenarios might you use a Queue instead of a Stack?

   


If you feel ready, take one of our timed public Software Engineering Interview Questions tests:
  • Software Engineering Online Test (Easy)
Not exactly what you are looking for? Go to our For Jobseekers section.