Reverse a Stack Using Recursion in Python

AmitDiwan
Updated on 15-Apr-2021 12:44:34

657 Views

When it is required to reverse a stack data structure using recursion, a ‘stack_reverse’ method, in addition to methods to add value, delete value, and print the elements of the stack are defined.Below is a demonstration of the same −Example Live Democlass Stack_structure:    def __init__(self):       self.items = []    def check_empty(self):       return self.items == []    def push_val(self, data):       self.items.append(data)    def pop_val(self):       return self.items.pop()    def print_it(self):       for data in reversed(self.items):          print(data) def insert_bottom(instance, data): ... Read More

Implement Stack Using One Queue in Python

AmitDiwan
Updated on 15-Apr-2021 12:43:52

814 Views

When it is required to implement a stack using a single queue, a ‘Stack_structure’ class is required along with a Queue_structure class. Respective methods are defined in these classes to add and delete values from the stack and queue respectively.Below is a demonstration of the same −Example Live Democlass Stack_structure:    def __init__(self):       self.q = Queue_structure()    def check_empty(self):       return self.q.check_empty()    def push_val(self, data):       self.q.enqueue_operation(data)    def pop_val(self):       for _ in range(self.q.size_calculate() - 1):          dequeued = self.q.dequeue_operation()         ... Read More

Get Details of Multiple Function Definitions from AWS Data Catalog Using Boto3

Ashish Anand
Updated on 15-Apr-2021 12:41:26

148 Views

Let's see how a user can get the details of multiple function definitions from AWS Glue Data Catalog.ExampleProblem Statement: Use boto3 library in Python to get the details of multiple function definitions present in a database(s) from AWS Glue Data Catalog.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: database_name and regular_pattern are optional parameters. If details are not provided for these, the function fetches the definition of all the functions present in AWS User account. If database_name is provided but regular_pattern is not provided, then it fetches all the functions in a given ... Read More

Get Details of User-Defined Function in AWS Glue Data Catalog Using Boto3

Ashish Anand
Updated on 15-Apr-2021 12:41:06

324 Views

Let's see how a user can get the details of a specified function definition from AWS Glue Data Catalog.ExampleGet the details of a function definition named as insert_employee_record in database employee.Problem Statement: Use boto3 library in Python to get the details of a specified function definition from AWS Glue Data Catalog.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: database_name and function_name are the required parameters. It fetches the definition of a given function_name in a given database.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default ... Read More

Get Details of Triggers Associated with a Job from AWS Glue Data Catalog Using Boto3

Ashish Anand
Updated on 15-Apr-2021 12:40:35

375 Views

In this article, we will see how a user can get the details of all the triggers associated with a job from AWS Glue Data Catalog.ExampleGet the details of all the triggers associated with a job - 'employee_details'.Problem Statement: Use boto3 library in Python to get the details of all the triggers that is associated with a job.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: job_name is the optional parameter for this function. If job_name is provided, it retrieves all the triggers those are associated with the same job and can start this ... Read More

Select Nth Largest Element from a List in Python

AmitDiwan
Updated on 15-Apr-2021 12:39:44

414 Views

When it is required to select the nth largest element from a list in linear time complexity, two methods are required. One method to find the largest element, and another method that divides the list into two parts. This division depends on the ‘i’ value that is given by user. Based on this value, the list is split, and the largest element is determined.Below is a demonstration of the same −Example Live Demodef select_largest(my_list, beg, end, i):    if end - beg k:       return select_largest(my_list, beg, pivot_val, i - k)    return my_list[pivot_val] def start_partition(my_list, ... Read More

Get Trigger Details from AWS Glue Data Catalog Using Boto3

Ashish Anand
Updated on 15-Apr-2021 12:38:49

323 Views

Let's see how a user can get the details of a trigger from AWS Glue Data Catalog.ExampleGet the details of a given trigger that is allowed in your account - '01_PythonShellTest1'.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: trigger_name is the required parameter for this function. It will fetch the details of the given trigger for a user account and then display its metadata.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating ... Read More

Difference Between Trigger and Procedure

AmitDiwan
Updated on 15-Apr-2021 07:48:12

2K+ Views

In this post, we will understand the difference between trigger and a procedure.TriggersIt is implicitly invoked when an event such as INSERT, DELETE, and UPDATE occurs in a table of a database.Nesting of triggers can be achieved using a table.A trigger can’t be called or defined inside another trigger.Transactional statements such as ‘COMMIT’, ‘ROLLBACK’, ‘SAVEPOINT’ can’t be used in triggers.They are used to maintain referential integrity.This is done by keeping a record of the activities performed on a table.No values are returned in a trigger.No value can be passed as a parameter to a trigger.Syntax to define a trigger:CREATE TRIGGER ... Read More

Difference Between ALTER and UPDATE Command in SQL

AmitDiwan
Updated on 15-Apr-2021 07:46:18

3K+ Views

In this post, we will understand the difference between the ALTER command and the UPDATE command in SQL.ALTER CommandThis command is a Data Definition Language (DDL).It performs operation at the structural level, not the data level.This command is used to add, delete, and modify the attributes of the tables in a database.This command, by default, initializes the values of all values in the tuple to NULL.It changes the structure of the table.Syntax: Add a column −ALTER TABLE table_name ADD column_name datatype;Drop a ColumnALTER TABLE table_name DROP COLUMN column_name;UPDATE CommandThis command is a Data Manipulation Language (DML).It performs operations on the ... Read More

Difference Between ROLAP and MOLAP

AmitDiwan
Updated on 15-Apr-2021 07:43:12

3K+ Views

In this post, we will understand the difference between ROLAP and MOLAP.ROLAPIt stands for Relational Online Analytical Processing.It is used for large volumes of data.The access time in ROLAP is slow.It stores data in the form of relation tables.The data in ROLAP is fetched from a data warehouse.It uses complex SQL queries.A static multidimensional view of the data is created in ROLAP.MOLAPIt stands for Multidimensional Online Analytical Processing.It is used for less/limited volumes of data.The access time is quick in MOLAP.Data is stored in a multidimensional array.Data is fetched from the MDDBs database.A sparse matrix is used in MOLAP.Dynamic multidimensional ... Read More

Advertisements