Categories
Computer Science Discovery Innovation Invention Learning Science Science and Technology Technology

Hello Everyone! Welcome to StellarRimz, the Science and Tech Hub

Welcome all to the new era of Science and Technology. There have been a lot of advancements in Science and Technology till now. So, we are here to get updated with all latest technologies and innovations. It’s going to be an interesting journey with you all!

Science and technology

Learning Sciences (LS) is an interdisciplinary field that works to further scientific, humanistic and critical theoretical understanding of learning as well as get involved in the design and implementation of innovations, and the improvement of instructional methods. Research in the learning sciences basically focuses on cognitive-psychological, social-psychological, cultural-psychological and critical theoretical foundations of human learning, as well as on designing of learning environments. Major contributing fields include cognitive science,  educational psychology,  computer science, applied linguistics and anthropology . Over the past decade, researchers have also expanded their concentrate to the design of curricula, informal learning environments, instructional methods, and policy innovations.

Why to Learn Science and get in touch with latest technologies?

Science and technology are closely related with our lives. They are closely linked aspects of society and the studies and developments in both these fields are very essential for the overall progress of mankind and humanity.

Scientific research mainly comprises of a wide variety of fields ranging from the study of different branches of science to relatively advanced fields like space exploration, Artificial Intelligence, Machine Learning, human genetics, and cloning. Scientific study attempts to explore and understand and innovate the working of the physical world. It tries to analyze and the occurrences in nature and gain knowledge about nature through experimentation. As scientific research targets at acquiring knowledge of the complexities in nature and finding solutions to unsolved problems, it is important for the progress of mankind. The seemingly impossible feats have been made possible, pay credit to scientific research and innovations in Technology.

Science and Technology

Types of Science studies:

  1. Natural Sciences.
  2. Artificial Sciences.

Natural sciences are concerned with the study of nature and human life. The Artificial Sciences deal with developing and inventing the new devices, scientific products, medicines, artificial technologies machines and infrastructure. The studies of natural and artificial sciences reveal the relationships between nature and human life. Research in science has paved a path to many brilliant inventions and discoveries.

The importance of technology resides in its manifold benefits to society. There are many positive effects of technology . The advancement in this area has revolutionized human life. It has provided an impetus to the computer and the telecommunication industry. The developments in communication technology have made the world a smaller place connecting every corner of the world. The Internet serving as an excellent communication platform has made the world flat and an easier to live place.

The World Wide Web has proved to be an enormous information network foundation, from which information can be retrieved by the means of search engines. Information from all around the world is clubbed and hosted on the web. Pay credits to development of web technology, the information can be stored in an organized manner and relevant information can be retrieved on supplying search strings to web search engines.

Digitization of information has been a major breakthrough in the world of information technology. It has made possible the compact storing of information, which in turn allows efficient information storage.

The most important benefit of science has been the luxury it has brought to daily life. The automation and machine advancement of industrial processes has reduced human efforts. Household appliances and and innovative products that are in daily use of the common man are a result of developments in science. Machines can do monotonous and risk-bearing tasks and hence protecting man from monotonous as well as dangerous but yet important tasks . Scientific discoveries have made human life easy and luxurious.

Without Science and Technology human life is almost unstable and meaningless.

Hope you enjoy the post! please drop your comments in below comments section. 🙂 Thank you for reading!

Categories
Computer Science

Object Oriented Programming – Polymorphism 

Polymorphism means “many forms”.
In OOP, it allows the same method name (or operator) to behave differently depending on the object or data type it is acting upon.

It helps in:

  • Code reusability
  • Flexibility
  • Maintainability

Python mainly supports runtime polymorphism (method overriding) and compile-time-like polymorphism (method overloading via default arguments or *args).

A single function can work with different types of objects.

Python
# Example: Same function name, different object types
class Dog:
def speak(self):
return "Woof!"
class Cat:
def speak(self):
return "Meow!"
def animal_sound(animal):
print(animal.speak())
# Using polymorphism
dog = Dog()
cat = Cat()
animal_sound(dog) # Woof!
animal_sound(cat) # Meow!

Here, animal_sound() works with any object that has a .speak() method — this is duck typing in Python.

Child classes can override methods from the parent class.

Python
class Bird:
def fly(self):
return "Some birds can fly."
class Sparrow(Bird):
def fly(self):
return "Sparrow flies high."
class Penguin(Bird):
def fly(self):
return "Penguins can't fly."
# Runtime polymorphism
for bird in [Sparrow(), Penguin()]:
print(bird.fly())

Output:

Sparrow flies high.
Penguins can't fly.

Many built-in functions in Python are polymorphic.

Python
print(len("Hello")) # Works on string → 5
print(len([1, 2, 3])) # Works on list → 3

Operators like +*, etc., behave differently for different data types.

print(5 + 10) # Integer addition → 15
print("Hi " + "Py") # String concatenation → Hi Py

You can define custom behavior using magic methods:

Python
class Book:
def __init__(self, pages):
self.pages = pages
def __add__(self, other):
return self.pages + other.pages
b1 = Book(100)
b2 = Book(200)
print(b1 + b2) # 300

Sure! Let’s break down polymorphism in Python in the context of Object-Oriented Programming (OOP).

  • Polymorphism lets the same interface work for different data types or classes.
  • In Python, it’s often achieved through method overridingduck typing, and operator overloading.
  • It improves code flexibility and reduces duplication.

If you want, I can prepare a single Python program that demonstrates all types of polymorphism in one place for easy learning.
Do you want me to create that?

Categories
Computer Science

Object Oriented Programming – Inheritance

Inheritance is a fundamental concept in object-oriented programming (OOP) that allows a class to inherit attributes and methods from another class. This promotes code reusability and establishes a hierarchical relationship between classes.

In Python, inheritance is implemented by defining a new class that derives from an existing class. The derived class (child class) inherits the attributes and methods of the base class (parent class). Here is a basic example:

Python
# Parent class
class Person:
def __init__(self, name, id):
self.name = name
self.id = id
def display(self):
print(self.name, self.id)
# Child class
class Employee(Person):
def print_emp(self):
print("Employee class called")
# Creating an object of the child class
emp = Employee("John", 101)
emp.display() # Calling parent class method
emp.print_emp() # Calling child class method

In this example, the Employee class inherits from the Person class, allowing it to use the display method defined in the Person class.

Python supports several types of inheritance:

  1. Single Inheritance: A child class inherits from a single parent class.
  2. Multiple Inheritance: A child class inherits from multiple parent classes.
  3. Multilevel Inheritance: A child class inherits from a parent class, which in turn inherits from another parent class.
  4. Hierarchical Inheritance: Multiple child classes inherit from the same parent class.
  5. Hybrid Inheritance: A combination of two or more types of inheritance.

Method overriding allows a child class to provide a specific implementation for a method that is already defined in its parent class. The super() function is used to call a method from the parent class.

Python
class Animal:
def speak(self):
return "Some sound"
class Dog(Animal):
def speak(self):
return "Woof!"
# Creating an instance of the Dog class
dog = Dog()
print(dog.speak()) # Output: Woof!

In this example, the Dog class overrides the speak method of the Animal class.

The super() function allows you to call methods from the parent class. This is useful for initializing the parent class’s attributes in the child class.

Python
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
class Student(Person):
def __init__(self, name, age, grade):
super().__init__(name, age)
self.grade = grade
# Creating an instance of the Student class
student = Student("Alice", 20, "A")
print(student.name, student.age, student.grade) # Output: Alice 20 A

In this example, super().__init__(name, age) calls the __init__ method of the Person class to initialize the name and age attributes.

Inheritance in Python is a powerful feature that promotes code reusability and allows for the creation of a hierarchical relationship between classes. By understanding and utilizing inheritance, you can create more efficient and maintainable code.

Categories
Computer Science

Object Oriented Programming – Abstraction

Abstraction is a fundamental concept in Object-Oriented Programming (OOP) that focuses on hiding the internal implementation details of a class or method while exposing only the necessary functionality. This simplifies code interaction, reduces complexity, and enhances maintainability.

In Python, abstraction is achieved using abstract classes and abstract methods, which are defined in the abc module.

An abstract class serves as a blueprint for other classes. It cannot be instantiated directly and must be subclassed. Abstract classes contain one or more abstract methods, which are declared but not implemented. Subclasses must provide their own implementation for these methods.

For example:

Python
from abc import ABC, abstractmethod
# Abstract class
class Animal(ABC):
@abstractmethod
def make_sound(self):
pass # Abstract method with no implementation
# Concrete subclass
class Dog(Animal):
def make_sound(self):
return "Bark"
# Instantiate the subclass
dog = Dog()
print(dog.make_sound()) # Output: Bark

In this example, Animal is an abstract class with an abstract method make_sound(). The Dog class implements the method, allowing it to be instantiated.

  1. Abstract Methods: Declared using the @abstractmethod decorator, these methods must be implemented by subclasses.
  2. Concrete Methods: Fully implemented methods in an abstract class that can be inherited by subclasses.
  3. Abstract Properties: Declared using @property and @abstractmethod, these enforce property implementation in subclasses.
Python
from abc import ABC, abstractmethod
class Vehicle(ABC):
@property
@abstractmethod
def wheels(self):
pass
class Car(Vehicle):
@property
def wheels(self):
return 4
car = Car()
print(car.wheels) # Output: 4

Here, wheels is an abstract property in the Vehicle class, and the Car class provides its implementation.

  • Simplifies Code: Users interact with high-level functionality without worrying about internal details.
  • Encapsulation: Sensitive or unnecessary details are hidden, reducing misuse or accidental changes.
  • Flexibility: Subclasses can define specific behaviors while adhering to a consistent structure.
  • Maintainability: Internal changes in abstract classes do not affect external code.
  • Abstract classes cannot be instantiated directly. Attempting to do so raises a TypeError.
  • Subclasses must implement all abstract methods and properties; otherwise, they too become abstract and cannot be instantiated.
Python
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self):
pass
# Attempting to instantiate an abstract class
shape = Shape() # Raises TypeError

Abstraction in Python is a powerful tool for designing robust and scalable applications by enforcing a clear structure and hiding unnecessary complexity.

Categories
Computer Science

Object Oriented Programming – Encapsulation

Encapsulation is an Object-Oriented Programming (OOP) concept where data (attributes) and methods (functions) are bundled together in a class and access to the data is controlled to protect it from unintended interference or misuse.

  • Data hiding (restricting direct access to variables)
  • Better maintainability
  • Controlled access through getter and setter methods

Python does not have strict access modifiers like some other languages, but it uses naming conventions:

ModifierSyntax ExampleMeaning
Publicself.nameAccessible from anywhere
Protectedself._nameConvention: should not be accessed outside the class (still possible)
Privateself.__nameName mangling makes it harder to access from outside
class BankAccount:
def __init__(self, account_holder, balance):
self.account_holder = account_holder # Public attribute
self._account_type = "Savings" # Protected attribute
self.__balance = balance # Private attribute
# Getter for balance
def get_balance(self):
return self.__balance
# Setter for balance with validation
def deposit(self, amount):
if amount > 0:
self.__balance += amount
print(f"Deposited ₹{amount}. New balance: ₹{self.__balance}")
else:
print("Deposit amount must be positive.")
def withdraw(self, amount):
if 0 < amount <= self.__balance:
self.__balance -= amount
print(f"Withdrew ₹{amount}. Remaining balance: ₹{self.__balance}")
else:
print("Invalid withdrawal amount.")
# Usage
account = BankAccount("Rahul", 5000)
# Public access
print(account.account_holder) # ✅ Works
# Protected access (possible but discouraged)
print(account._account_type) # ⚠️ Works but not recommended
# Private access (will cause error)
# print(account.__balance) # ❌ AttributeError
# Correct way to access private data
print("Balance:", account.get_balance())
# Modify balance safely
account.deposit(2000)
account.withdraw(1000)
  1. Public: Accessible anywhere.
  2. Protected: Accessible but should be treated as internal.
  3. Private: Not directly accessible; use getters/setters.
  4. Name Mangling: Private attributes are internally renamed to _ClassName__attribute to avoid accidental access.

Categories
Computer Science

Object Oriented Programming

(OOP)

Object-Oriented Programming (OOP) is a programming paradigm that organizes software design around objects — entities that combine data (attributes) and behavior (methods). It models real-world entities and promotes modularityreusability, and maintainability in code.

At its core, OOP uses classes as blueprints to create objects. A class defines the structure (attributes) and capabilities (methods) of its objects, while each object is an instance with its own state.

  • Class – A template or a blueprint that define attributes and methods.
  • Object – An instance of a class with specific data.
  • Attributes – Variables that store the state of an object.
  • Methods – Functions inside a class that define object behavior.
  1. Encapsulation – Bundling data and methods, restricting direct access to internal state.
  2. Abstraction – Hiding complex implementation details, exposing only necessary functionality.
  3. Inheritance – Allowing a class (child) to acquire properties and behaviors from another (parent).
  4. Polymorphism – Enabling the same method name to behave differently based on the object.
  • Code Reusability via inheritance.
  • Modularity for easier debugging and maintenance.
  • Security through encapsulation.
  • Flexibility with polymorphism for adaptable behaviors.

Categories
Computer Science

Solving Problem: Balanced Parenthesis

Data Structures – Stacks

Problem Statement:

You are given a block of code or a string. Check for balanced parenthesis.

Example:

Sample Input1:

" # Example: Python code with unbalanced parentheses \
def add_numbers(a, b): \
return (a + b # Missing closing parenthesis \
# Calling the function \
result = add_numbers(5, 3) \
print('Result':, result) "

Expected Output1:

False

Sample Input2:

" # Example: Python code with unbalanced parentheses \
def add_numbers(a, b): \
return (a + b) # Closed parenthesis \
# Calling the function \
result = add_numbers(5, 3) \
print('Result':, result) "

Expected Output2:

True

Solution:

# Balanced parentheses
def is_balanced(s):
stack = []
mapping = {')':'(', ']':'[', '}':'{'}
for char in s:
if char in mapping.values():
stack.append(char)
elif char in mapping:
if not stack or stack.pop() != mapping[char]:
return False
return not stack
string1 = " # Example: Python code with unbalanced parentheses \
def add_numbers(a, b): \
return (a + b # Missing closing parenthesis \
# Calling the function \
result = add_numbers(5, 3) \
print('Result':, result) "
print(is_balanced(string1))

Output:

Categories
Computer Science

Solving Problem: Combine Two Linked Lists

Data Structures – Linked List

Problem Statement:

You are given the heads of two sorted linked lists list1 and list2.

Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists.

Return the head of the merged linked list.

Example 1:

1 -> 2 -> 4 -> NULL

1 -> 3 -> 4 -> NULL

Expected Output:

1 -> 1 -> 2 -> 3 -> 4 -> 4 -> NULL

Input: list1 = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]

Example 2:

Input: list1 = [], list2 = []
Output: []

Example 3:

Input: list1 = [], list2 = [0]
Output: [0]

Constraints:

  • The number of nodes in both lists is in the range [0, 50].
  • -100 <= Node.val <= 100
  • Both list1 and list2 are sorted in non-decreasing order.

Solution:

Python
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def mergeTwoLists(list1, list2):
arr = []
while list1 is not None:
arr.append(list1.val)
list1 = list1.next
while list2 is not None:
arr.append(list2.val)
list2 = list2.next
arr.sort()
temp = ListNode(-1)
curr = temp
for value in arr:
curr.next = ListNode(value)
curr = curr.next
return temp.next
def printList(node):
while node:
print(node.val, end=" -> ")
node = node.next
print("NULL")
if __name__ == "__main__":
head1 = ListNode(1)
head1.next = ListNode(2)
head1.next.next = ListNode(4)
head2 = ListNode(1)
head2.next = ListNode(3)
head2.next.next = ListNode(4)
result = Solution.mergeTwoLists(head1, head2)
printList(result)

Output:

Reference: Merge In Between Linked Lists – LeetCode

Categories
Learning Technology

Solving Problem: Reverse a Linked List

Data Structures – Linked List

Problem Statement:

You are given a Linked List. Reverse the Linked List.

Example 1:

Input:

1 -> 2 -> 3 -> 4 -> 5 -> NULL

Expected Output:

5 -> 4 -> 3 -> 2 -> 1 -> NULL

Solution:

Python:

Python
class Node:
def __init__(self, data):
self.data = data
self.next = None
def reverse_list(head):
prev = None
curr = head
while curr:
next = curr.next
curr.next = prev
prev = curr
curr = next
return prev
def print_list(node):
while node:
print(node.data, end=" -> ")
node = node.next
print("NULL")
# Example usage
head = Node(1)
head.next = Node(2)
head.next.next = Node(3)
head.next.next.next = Node(4)
head.next.next.next.next = Node(5)
print("Given Linked List:")
print_list(head)
reversed_head = reverse_list(head)
print("Reversed Linked List:")
print_list(reversed_head)

Output:

Categories
Computer Science

Solving Problem: Sliding Window Maximum

Arrays and Strings

Problem Statement:

You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.

Return the max sliding window.

Example 1:

Input: nums = [1,3,-1,-3,5,3,6,7], k = 3
Output: [3,3,5,5,6,7]
Explanation:
Window position Max
--------------- -----
[1 3 -1] -3 5 3 6 7 3
1 [3 -1 -3] 5 3 6 7 3
1 3 [-1 -3 5] 3 6 7 5
1 3 -1 [-3 5 3] 6 7 5
1 3 -1 -3 [5 3 6] 7 6
1 3 -1 -3 5 [3 6 7] 7

Example 2:

Input: nums = [1], k = 1
Output: [1]

Constraints:

  • 1 <= nums.length <= 105
  • -104 <= nums[i] <= 104
  • 1 <= k <= nums.length

Python:

class Solution:
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
# Write your code here
max_array = []
for i in range(0, len(nums) - k + 1):
window_max = max(nums[i:i+k])
max_array.append(window_max)
return max_array
Categories
Computer Science

Understanding Computer Architecture

The Basics – You Must Know

A computer is an electronic machine or a programmable device that can store, retrieve and process data.

Computer ArchitectureThe von Neumann Architecture

The CPU is the brain of the computer, consisting of:

Arithmetic Logic Unit (ALU): Performs arithmetic and logical operations.

Control Unit (CU): Directs the flow of data and instructions.

Registers: Small, high-speed storage for temporary data.

Example: In an Intel i7 processor, the ALU handles integer and floating-point calculations, while the CU manages instruction sequencing.

Memory stores data and instructions for processing. It is organized in a hierarchy:

Primary Memory: RAM (volatile) and cache (fast access).

Secondary Memory: Hard drives, SSDs (non-volatile).

Virtual Memory: Extends RAM using disk space.

Example: A system with 16GB RAM and 512GB SSD uses paging to manage virtual memory.

Handles communication between the CPU and external devices.

I/O Interfaces: Memory-mapped or isolated I/O.

Interrupts & DMA: Efficient data transfer without CPU intervention.

Example: A keyboard sends interrupts to the CPU, while a disk uses DMA for bulk data transfer.

Buses are communication pathways for data, addresses, and control signals.

Data Bus: Transfers actual data.

Address Bus: Specifies memory locations.

Control Bus: Manages read/write operations.

Example: PCIe bus connects GPUs to the CPU for high-speed data exchange.

Improves performance by overlapping instruction execution stages.

Instruction Level Parallelism (ILP) and Branch Prediction reduce delays.

Example: Modern CPUs like ARM Cortex-A use 5-stage pipelines to execute multiple instructions simultaneously.

Defines the CPU’s commands, addressing modes, and data formats.

Reduced Instruction Set Computer (RISC): Simple, fast instructions (e.g., ARM).

Complex Instruction Set Computer (CISC): Complex instructions (e.g., x86).

Example: ARM ISA powers most smartphones for energy efficiency.