EdPresso Roundup: Top 5 flavors
Tags: oop, unix, java, python
Published: 2020-01-09 18:43:40

EdPresso shots are a new kind of Espresso shot but, instead of waking your body up with caffeine, they wake your mind up with knowledge. Just like shots of espresso, [EdPresso shots](https://www.educative.io/edpresso) are short and concentrated bits of coding knowledge, organized in an open-access library for developers of all skill levels. The time it takes to read one rarely exceeds four minutes, no matter the difficulty of the topic. 

Also, like espresso shots, EdPressos come in many different flavors, some more popular than others. There are five shots that seem to have won over developers around the world. In this post, we will explore the top 5 questions searched by developers like you. 

___

## 1. What is Object-Oriented Programming?

First, we define the difference between classes and objects: "an Object may contain data (fields or variables) or code (methods or procedures). The creation of these objects is based on a programmer-defined blue-print also known as a Class." This shot then breaks down the four basic principles of [OOP](https://www.educative.io/edpresso/what-is-objectoriented-programming) (Object-oriented programming): inheritance, polymorphism, abstraction, and encapsulation. 

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/3mtjkhc9ljp1c9ronx0k.png)

Since languages like Java, Smalltalk, Python, Fortran, Eiffel, etc. all use OOP, it makes a lot of sense that so many developers are curious about this shot. 

___


## 2. What are some basic UNIX commands?

The shot begins with a short definition of a command: is an instruction to the computer, which it interprets to perform a specific task. It then breaks down commands in detail, including Listing Files `ls`, Change Directory `cd`, Make Directory `mkdir`, Remove Film `rm`, and Manual `man`. Under each command header, there is an explanation of why the command is used and a real-life example that you can compile on the webpage yourself.  [Learn these basic commands](https://www.educative.io/edpresso/what-are-some-basic-unix-commands) to get started with the command line. For a comprehensive list of UNIX commands, you can visit this [Bash cheat sheet](https://www.educative.io/blog/bash-shell-command-cheat-sheet).

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/1gh8d9b7q5hx0njmo3s9.png)

___

## 3. How do you reverse a string in Python?

[Number 3](https://www.educative.io/edpresso/how-do-you-reverse-a-string-in-python) beings by defining strings: ordered sequences of character data. In Python, there is no built-in method to reverse a string, but there are three different ways in which strings can be reversed (i.e., Slicing, Loop, and Use join). With Slicing, we simply create a slice that starts with the length of the string, and ends at index 0. With Loop, we create a new array called `reversedString[]` and then loop over the list with iterating variable index initialized with the length of the list. With Use join, we use reverse iteration with the `reversed( )` built-in function to cycle through the elements in the string in reverse order and then use `.join()` method to merge them. If you want to get hands-on practice, take a look at [shot](https://www.educative.io/edpresso/how-do-you-reverse-a-string-in-python) and run the code in real-time.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/h6vg4dyr6euqwqwn4cc9.png)

___

## 4. How to use switch case statement in Java

First, we define a `switch` statement: these are is used to transfer control to a particular block of code, based on the value of the variable being tested. They are an efficient alternative for `if-else` statements. The switch is passed a variable, the value of which is compared with each case value. If there is a match, the corresponding block of code is executed.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/e87oxfdbji42pjxarbbr.png)

[Try this powerful alternative to the if-else statement in real time.](https://www.educative.io/edpresso/how-to-use-switch-case-statement-in-java)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/fztptvopaa4av30kul1v.png)

___

## 5. Min Heap vs. Max Heap

This shot compares min and max heap with clear visuals and applications. 

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/uueyx9ii28vkor820qcw.png)

It then breaks down the time complexity for each. 
* **Get Max or Min Element:** The Time Complexity of this operation is O(1).
* **Remove Max or Min Element:** The time complexity of this operation is O(Log n) because we need to maintain the max/mix at their root node, which takes Log n operations.
* **Insert an Element:** Time Complexity of this operation is O(Log n) because we insert the value at the end of the tree and traverse up to remove violated property of min/max heap.

You can learn more about this topic [here](https://www.educative.io/edpresso/min-heap-vs-max-heap).